
27 Feb
2011
27 Feb
'11
11:47 a.m.
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?