In my template “smart pointer” class, I want to have separate constructors and assignment operators that take as arguments, respectively, lvalue and rvalue pointers. How should I write the functions?
In my template smart pointer class, I want to have separate constructors and assignment
Share
In C++11 it’s really easy, because an overload accepting an rvalue reference doesn’t take precedence over one accepting an lvalue reference, but rvalues and only rvalues may bind to the former:
(Obviously the above overload constructions can be applied to your member functions, too.)
I’m not sure how you’d go about it in C++03, though. I think Boost has
is_rvaluethat you could play with in template parameters.