I have a quick question about encapsulating specific types with typedef
. Say I have a class Foo
whose constructor takes a certain value, but I want to hide the specific type using typedef
:
class Foo {
public:
typedef boost::shared_ptr< std::vector<int> > value_type;
Foo(value_type val) : val_(val) {}
private:
value_type val_;
};
But in this case, the main function still has to know the type (so it's explicitly using std::vector<int>
):
int main() {
Foo::value_type val(new std::vector<int>());
val->push_back(123);
Foo foo(val);
return 0;
}
How can I fix that while still avoiding a deep copy of the vector in the Foo
constructor?