Boost logo

Boost :

Subject: Re: [boost] [Gauge for interest] Surrogate template
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2011-02-27 06:47:28


On 27/02/2011 07:56, Alan sinde wrote:

> Example Usage:
>
> class boy
> {
> public:
> virtual void tell() = 0;
> };
>
> class happy_boy : public boy
> {
> ...
> };
> class study_boy : public boy
> {
> ...
> };
>
> void say_hi(boy& the_boy)
> {
> the_boy.tell();
> }
>
> int main()
> {
> std::cout<< "Hello boost::surrogate!"<< std::endl;
> happy_boy Terry;
> study_boy Thomas;
>
> std::vector<boost::surrogate<boy> > boy_list;
> boy_list.push_back(boost::surrogate<boy>(Terry));
> boy_list.push_back(boost::surrogate<boy>(Thomas));
>
> std::for_each(boy_list.begin(), boy_list.end(), say_hi);
>
> std::cin.get();
> }

How is that different from clone_ptr and other similar works?


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk