So I have an aggregate class Foo
which takes moveable and (indirectly) copyable arguments (A class called Image_t
, and a std::unique_ptr<Map>
, and Map can clone itself).
I want to give the end user flexibility in how they create the class. So I have a "copy-like" constructor and a "move-like" constructor:
typdef std::unique_ptr<Map> MapPtr;
///
///@brief Copy build constructor
///
Foo(const Image_t& image, const MapPtr& map_ptr) :
image_(image),
geo_locatormap_(map_ptr->clone())
{
}
///
///@brief Move build constructor
///
Foo(Image_t&& image, MapPtr&& map_ptr) :
image_(std::move(image))
geo_locatormap_(std::move(map_ptr))
{
}
Now ideally, I'd like to have Foo(const Image_t& image, MapPtr&& map_ptr)
and Foo(Image_t&& image, const MapPtr& map_ptr)
as well, but I'm feeling like this is duplicating effort. Is there a quick way to do this? Or is this type of constructor frowned upon?