
Thanks Roman.
so is this how i would use your implementation?
boost::shared_ptr<Test> t = newptr<int, char, std::string>(1, 'a', "hello");
that is getting a lot closer to what i need. and is far better that a MACRO. declaring the types may annoying however.
the good thing about this approach it that is will also be exception safe: ie i dont need to declare a variable for the shared_ptr. and will be cleaned up if g() fails
// exception safe fn(newptr<int, char, std::string>(1, 'a', "hello"), g());
You can omit all but the first template parameters because they can be deduced by compiler. shared_ptr<Test> t = newptr<Test>(1, 'a', "hello"); which is equivalent to shared_ptr<Test> t = shared_ptr<Test>(new Test(1, 'a', "hello")); HTH, Roman Perepelitsa.