Using Adaptable Generator concept with generate_n and boost smart pointers
Hi boosters,
I'm trying to create a class that models the concept of adaptable
generator [1]. The idea is that it generates pointers to test data
objects which I'd like to then put inside of smart pointers such as
shared_ptr or scoped_ptr (or even std::shared_ptr) via generate_n,
etc. This is a (non-compilable) example of my intentions:
#include <algorithm>
#include <iostream>
#include <memory>
#include <vector>
#include <iterator>
struct base { int i; };
struct derived : public base { int z; };
struct generator
{
typedef base result_type;
result_type* operator()() {
return new derived();
}
};
int main(void) {
std::vector
participants (1)
-
Marco Craveiro