Dears
I have question.
Why there are problems to connect function that returns auto_ptr to the
signal? Below there is a code which won't compile i line where is comment.
Regards.
#include <iostream>
#include
#include
#include
#include <memory>
#include <vector>
#include <iterator>
#include <algorithm>
class some_class {
public:
::std::vector <int> func1() {
using ::std::vector;
typedef vector <int> Res;
Res res (2);
res.at(0) = 13;
res.at(1) = 14;
return res;
}
::boost::shared_ptr < ::std::vector <int> > func2() {
using ::std::vector;
using ::boost::shared_ptr;
typedef shared_ptr < vector <int> > Res;
Res res (new vector<int> (2));
res->at(0) = 23;
res->at(1) = 24;
return res;
}
::std::auto_ptr < ::std::vector <int> > func3() {
using ::std::vector;
using ::std::auto_ptr;
typedef auto_ptr < vector <int> > Res;
Res res (new vector<int> (2));
res->at(0) = 33;
res->at(1) = 34;
return res;
}
};
int main()
{
using ::boost::signal;
using ::std::vector;
using ::std::auto_ptr;
using ::boost::shared_ptr;
using ::boost::bind;
some_class sc;
signal < vector <int> (void) > sig1;
signal < shared_ptr < vector <int> > (void) > sig2;
signal < auto_ptr < vector <int> > (void) > sig3;
sig1.connect (bind (&some_class::func1,&sc));
vector <int> ret1 (sig1());
::std::copy (ret1.begin(), ret1.end(),
::std::ostream_iterator<int> (::std::cout, "\n"));
sig2.connect (bind (&some_class::func2,&sc));
vector <int> ret2 (*sig2());
::std::copy (ret2.begin(), ret2.end(),
::std::ostream_iterator<int> (::std::cout, "\n"));
sig3.connect (bind (&some_class::func3,&sc));
//sig3(); // <- ERROR
}
--
|\/\/| Seweryn Habdank-Wojewódzki
\/\/