language: C++ 4.7.2 (gcc-4.7.2)
date: 225 days 5 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cstdlib>
#include <iostream>
#include <boost/type_traits.hpp>
#include <boost/utility/enable_if.hpp>
 
template<typename T>
struct Foo
{
        typename boost::enable_if_c<boost::is_same<char,T>::value >::type
        bar();
        
        typename boost::disable_if_c<boost::is_same<char,T>::value >::type
        bar();
};
 
template<typename T>
typename boost::disable_if_c<boost::is_same<char,T>::value >::type
Foo<T>::bar()
{
        std::cout << "I am generic ..." << std::endl;
}
 
template<typename T>
typename boost::enable_if_c<boost::is_same<char,T>::value >::type
Foo<T>::bar()
{
        std::cout << "I am specific ..." << std::endl;
}
 
int main()
{
        Foo<char> f1;
        f1.bar();
        
        return EXIT_SUCCESS;
}
 
prog.cpp:13: error: ‘typename boost::disable_if_c<boost::is_same::value, void>::type Foo<T>::bar()’ cannot be overloaded
prog.cpp:10: error: with ‘typename boost::enable_if_c<boost::is_same::value, void>::type Foo<T>::bar()’
prog.cpp:18: error: prototype for ‘typename boost::disable_if_c<boost::is_same::value, void>::type Foo<T>::bar()’ does not match any in class ‘Foo<T>’
prog.cpp:10: error: candidate is: typename boost::enable_if_c<boost::is_same::value, void>::type Foo<T>::bar()