language: C++11 (gcc-4.7.2)
date: 722 days 10 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <string>
#include <iostream>
 
template<typename T = int> void Add(...) {
    static_assert(sizeof(T) == 0, "Must be addable!");
}
 
template<typename T1, typename T2> auto Add(T1&& t1, T2&& t2) ->
  decltype(std::forward<T1>(t1) + std::forward<T2>(t2)) {
    return std::forward<T1>(t1) + std::forward<T2>(t2);
}
 
struct f {};
 
int main() {
    std::cout << Add(std::string("Hello"), std::string(" world!"));
    Add(f(), f());
}
 
prog.cpp: In function 'void Add(...) [with T = int]':
prog.cpp:17:17:   instantiated from here
prog.cpp:5:5: error: static assertion failed: "Must be addable!"