The copy constructor only actually compiles when all member types are copyable, as it should. However, when checking whether the variant type is copy-constructible via SFINAE, e.g. with std::is_copy_constructible, you will always get true, because the copy constructor always exists, whether or not it is valid. The same applies to move constructors, and copy / move assignment operators.
I first thought I could fix this with a simple enable_if on each of the methods, but as it turns out I can't because if you make templates out of any of these special methods, they are not those special methods anymore. I did find a solution on StackOverflow, though I'm not entirely certain if it might introduce unwanted side effects. Could you have a look? In case it seems unproblematic to you, I would be happy to try implementing it here.
The copy constructor only actually compiles when all member types are copyable, as it should. However, when checking whether the variant type is copy-constructible via SFINAE, e.g. with
std::is_copy_constructible
, you will always gettrue
, because the copy constructor always exists, whether or not it is valid. The same applies to move constructors, and copy / move assignment operators.I first thought I could fix this with a simple
enable_if
on each of the methods, but as it turns out I can't because if you make templates out of any of these special methods, they are not those special methods anymore. I did find a solution on StackOverflow, though I'm not entirely certain if it might introduce unwanted side effects. Could you have a look? In case it seems unproblematic to you, I would be happy to try implementing it here.