On 5/23/2013 9:57 AM, Pekka Seppänen wrote:
On 23.5.2013 16:40, Igor R wrote:
It seems to be a MSVC related issue; Unless the templated function (make_shared in this case) is in the same namespace as the called templated function (f in this case) MSVC throws an error.
Good finding, thanks!
Note however that the following does compile in MSVC:
#include
#include void f(int, boost::shared_ptr<int> = boost::make_shared<int>()) { } int main() { f(0); } So, it's still unclear in what cases exactly this bug occurs.
The bug occurs if both the default argument and the function that has the default argument are templated. There could be some other cases too, but either a) move everything under the same namespace scope, b) drop f() template, c) drop default argument template (eg. non-templated make_shared wrapper if the make_shared type does not relate to f()'s templated type T); Every option sucks, just pick your poison.
So, template < typename T > void foo(T, arg_type arg = ns::templated< some_type >()) does not work, but void foo (arg_type arg = ns::templated< some_type >()) and template < typename T > void foo(T, arg_type arg = ns::not_templated()) work.
Typical MSVC everyday bs...
and the above code continues to faile to compile with MSVC11. Jeff