|
Boost : |
Subject: Re: [boost] [concept] forward declarations and `BOOST_CONCEPT_REQUIRES()`
From: Stefan van Kessel (van_kessel_at_[hidden])
Date: 2010-08-10 20:00:03
On 8/10/2010 11:20 PM, Stephan T. Lavavej wrote:
> (If VC10, aka 1600, is doing something wrong here, I'd like to know about it - with a self-contained repro.)
This is what I think it boils down to:
template <int check>
struct IntToVoid
{
typedef void type;
};
template <typename T>
struct TypeToZero
{
enum { value = 0 };
};
template <typename T>
struct Empty
{
};
template<typename T>
typename IntToVoid<(TypeToZero<Empty<T> >::value ) >::type
foo();
template<typename T>
typename IntToVoid<(TypeToZero<Empty<T> >::value ) >::type
foo()
{}
int main() {
foo<int>();
return 0;
}
1>------ Build started: Project: test, Configuration: Debug x64 ------
1> main.cpp
1>main.cpp(31): error C2668: 'foo' : ambiguous call to overloaded function
1> main.cpp(25): could be 'IntToBool<check>::type foo<int>(void)'
1> with
1> [
1> check=0
1> ]
1> main.cpp(20): or 'IntToBool<check>::type foo<int>(void)'
1> with
1> [
1> check=0
1> ]
1> while trying to match the argument list '(void)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If one omits the () around TypeToZero<Empty<T> >::value, it compiles
just fine:
template<typename T>
typename IntToVoid<TypeToZero<Empty<T> >::value >::type
foo();
template<typename T>
typename IntToVoid<TypeToZero<Empty<T> >::value >::type
foo() {}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk