Is there a reason why the implicit copy constructor for a struct containing an enum would not use the const version – or why there is no copy-constructor at all? I would expect an implicit copy-constructor being created, i.e.:
X(const X& x)
I know there are rules for when this might happen, for instance if a member variable does not have a copy constructor, or a non-const copy constructor. I guess my question is how this relates to enums – and if it is this rule that applies?
Adding my own copy constructor seems to work.
Example – what, if any, copy-constructors are created implicitly:
struct MyStruct {
int myInt;
double myDouble;
MyEnum myEnum;
};
Your guess about enums is wrong; the problem is somewhere else. The following code compiles with no problem if no copy constructor is explicitly defined, and fails to compile if there is a copy constructor taking a non-const reference.
As others pointed out in comments, a realistic example demonstrating the error is required to understand what’s the real problem.