Closed YanB25 closed 1 year ago
The problem is in your code, not range-v3:
int main() {
Wrapper<int> a;
Wrapper<int> b = a; // error
}
The ranges::to
construction fails ultimately for the same reason that the construction of b
there fails. You need to be careful when writing forwarding reference constructors that you don't take priority over the copy constructor from a non-const lvalue.
Thank you to your timely reply! It works.
And I realized a good way to implement this wrapper is similar to std::optional
's constructor: taking an std::in_place_t
.
Minimal Reproducible Codes
Expected Behaviour
The code should compile.
Compile Error Messages
Env
Also, I don't know whether it is a bug or an expected behaviour (a feature). Please let me know if you can help me workaround this case.