|
Boost : |
Subject: [boost] enable_if quirk? bug?
From: Gennadiy Rozental (rogeeff_at_[hidden])
Date: 2012-11-11 02:20:46
Hi,
While working on some portability for Boost.Test I found this weird behavior.
Abstracting out Boost.Test specific staff it goes like this:
template<typename T>
inline typename boost::enable_if_c<!boost::is_float<T>::value, int>::type
foo( T&& v );
template<typename T>
inline typename boost::enable_if_c<!boost::is_float<T>::value, int>::type
foo( T&& v )
{
return 1;
}
...
foo(1);
MSVC 10 producing this error:
error C2668: 'foo' : ambiguous call to overloaded function
test.cpp(31): could be 'int foo<int>(T &&)'
with
[
T=int
]
test.cpp(27): or 'int foo<int>(T &&)'
with
[
T=int
]
while trying to match the argument list '(int)'
Now change boost::enable_if_c with seemingly equivalent std::enable_if:
template<typename T>
inline typename std::enable_if<!boost::is_float<T>::value, int>::type
foo( T&& v );
template<typename T>
inline typename std::enable_if<!boost::is_float<T>::value, int>::type
foo( T&& v )
{
return 1;
}
and MSVC 10 is happy to accept this code.
This is somewhat unfortunate since I hoped to use boost::enable_if across
compilers.
Gennadiy
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk