P
Philipp Reh
Dear group,
I recently tried to port some of my code to a VC++8.0 environment. I
noticed that some boost::enable_if related code fails to compile there
which works under gcc.
I've made a minimal example to illustrate the matter.
#include <boost/utility/enable_if.hpp>
namespace test
{
template<typename T> struct traits {
enum { two_params = false };
};
template<> struct traits<int> {
enum { two_params = true };
};
class foo {
public:
template<typename T>
typename boost::enable_if_c<traits<T>::two_params == false,
void>::type test_fun(int);
template<typename T>
typename boost::enable_if_c<traits<T>::two_params == true,
void>::type test_fun(int,int);
};
}
template<typename T>
typename boost::enable_if_c<test::traits<T>::two_params == false,
void>::type test::foo::test_fun(int)
{
}
template<typename T>
typename boost::enable_if_c<test::traits<T>::two_params == true,
void>::type test::foo::test_fun(int,int)
{
}
int main()
{
test::foo f;
f.test_fun<int>(1,2);
}
It fails with saying that it can't find a matching definition to and
existing declaration for both of the function definitions.
I would like to know if this code is standard compilant or not.
And please excuse the little use of a boost helper class.
I recently tried to port some of my code to a VC++8.0 environment. I
noticed that some boost::enable_if related code fails to compile there
which works under gcc.
I've made a minimal example to illustrate the matter.
#include <boost/utility/enable_if.hpp>
namespace test
{
template<typename T> struct traits {
enum { two_params = false };
};
template<> struct traits<int> {
enum { two_params = true };
};
class foo {
public:
template<typename T>
typename boost::enable_if_c<traits<T>::two_params == false,
void>::type test_fun(int);
template<typename T>
typename boost::enable_if_c<traits<T>::two_params == true,
void>::type test_fun(int,int);
};
}
template<typename T>
typename boost::enable_if_c<test::traits<T>::two_params == false,
void>::type test::foo::test_fun(int)
{
}
template<typename T>
typename boost::enable_if_c<test::traits<T>::two_params == true,
void>::type test::foo::test_fun(int,int)
{
}
int main()
{
test::foo f;
f.test_fun<int>(1,2);
}
It fails with saying that it can't find a matching definition to and
existing declaration for both of the function definitions.
I would like to know if this code is standard compilant or not.
And please excuse the little use of a boost helper class.