c++ - error: use of deleted function -


i've been working on c++ code friend has written , following error have never seen before when compiling gcc4.6:

error: use of deleted function  ‘gamefsm_<std::array<c, 2ul> >::hdealt::hdealt()’ implicitly deleted because default definition ill-formed: uninitialized non-static const member ‘const h_t floppokergamefsm_<std::array<c, 2ul> >::hdealt::h’ 

edit: comes part of code using boost msm: boost webpage

edit2: there no = delete() used anywhere in sourcecode.

generally speaking, error mean? should looking when type of error occurs?

i don't think other answers mentioning =deleted; syntax correct. error message says default constructor has been deleted implicitly. says why: class contains non-static, const variable, not initialized default ctor.

class x {     const int x; }; 

since x::x const, must initialized -- default ctor wouldn't initialize (because it's pod type). therefore, default ctor, need define 1 (and must initialize x). can same kind of situation member that's reference:

class x {      whatever &x; }; 

it's worth noting both of these disable implicit creation of assignment operator well, , same reason. implicit assignment operator members-wise assignment, in these cases can't because member 1 can't assigned. make assignment work, need write own assignment operator.

this why const member should typically static -- when assignment, can't assign const member anyway. in typical case instances going have same value might share access single variable instead of having lots of copies of variable have same value.

it possible, of course, create instances different values though -- (for example) pass value when create object, 2 different objects can have 2 different values. if, however, try swapping them, const member retain original value instead of being swapped.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -