
Hi,
I am using boost::list_of to pass a vector of pairs of string +
"unsigned char" to SomeClass (as it can be seen in the typedef below -
keys_t). This passes the whole vector to SomeClass which copies the
vector in the keys_ private variable. The problem is: the copy ctor now
copies the full vector in each SomeClass. To prevent this, as you can
see, I have defined another data member which is a reference to const
keys_t in my class and am initializing it in the member initialization
list of the constructor with the value of keys_ and having the copy
constructor copy just the reference of keys_ (rkeys_, that is - as you
can see in the member initialization list of the copy ctor) instead of
the full vector but the new SomeClass then holds an uninitialized vector
(keys_) which is ugly and I hate seeing it in the class. Can I possible
use Boost::make_shared with boost::list_of to return me a pointer to
whatever (vector of type keys_t) boost::list_of returns and store that
pointer instead in my class (e.g. keys_t typedef then reflects
boost::shared_ptr instead of a traditional pointer) instead of the full
vector. Specifying the arbitrary constants (apparently using
boost::list_of) right in the constructor call is a requirement. Is there
any way I can do it? Of course, I guess I could use boost::make_shared
to return me a boost::shared_ptr to keys_t but my code is not even
compiling and giving me errors in boost headers:
std::vector