Boost logo

Boost Users :

From: Meryl Silverburgh (silverburgh.meryl_at_[hidden])
Date: 2006-02-18 00:11:10


My case is using a vector of a pointer of a Class say 'A' which that
class's constructor is private.

On 2/17/06, me22 <me22.ca_at_[hidden]> wrote:
> On 2/17/06, Meryl Silverburgh <silverburgh.meryl_at_[hidden]> wrote:
> > Why boost is trying to make a copy of A (a vector is a list of A*).
> >
> > And how can I fix that without making A constructor public?
> >
>
> I have no idea why it'd be doing that -- some more code would be helpful.
>
> The following testcase seems to work fine:
> #include <iostream>
> #include <vector>
> #include <algorithm>
> #include <boost/bind.hpp>
>
> template <typename T>
> struct dereference_as {
> typedef T& result_type;
> template <typename P>
> result_type operator()(P ptr) {
> return *ptr;
> }
> };
>
> void showfirst(char c) { std::cout << c << std::endl; }
>
> int main() {
>
> std::vector<char const*> v;
> v.push_back( "1" );
> v.push_back( "2" );
> v.push_back( "3" );
> v.push_back( "4" );
> v.push_back( "5" );
> v.push_back( "6" );
>
> std::for_each( v.begin(), v.end(),
> boost::bind( &showfirst, boost::bind(
> dereference_as<char const>(), _1 ) ) );
> }
>
>
> ~ Scott
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net