I ran into some kind of problem and cannot decide which is the right solution.
Here is an example code to illustrate:
#include <boost/make_shared.hpp>
#include <boost/shared_ptr.hpp>
class TestClass{
public:
int a;
TestClass(int& a,int b){};
private:
TestClass();
TestClass(const TestClass& rhs);
};
int main(){
int c=4;
boost::shared_ptr<TestClass> ptr;
ptr=boost::shared_ptr<TestClass>(new TestClass(c,c));
}
The problem is that I cannot create an instance of shared_ptr because make_shared receives and passes arguments to the TestClass constructor as "const A1 &, const A2 & ...", as described:
template<typename T, typename Arg1, typename Arg2 >
shared_ptr<T> make_shared( Arg1 const & arg1, Arg2 const & arg2 );
I can cheat with boost :: shared (new ...) or rewrite the constructor for const links, but it doesn't seem to be the way it should be.
Thnx in advance!
source
share