1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <functional> template <typename T> class A { typedef decltype(std::bind(&A::f, std::declval<A>())) some_type; void f(); }; template <> class A<void> { void f(); typedef decltype(std::bind(&A::f, std::declval<A>())) some_type; }; int main() { return 0; } |
I2luY2x1ZGUgPGZ1bmN0aW9uYWw+CnRlbXBsYXRlIDx0eXBlbmFtZSBUPgpjbGFzcyBBCnsKICAgIHR5cGVkZWYgZGVjbHR5cGUoc3RkOjpiaW5kKCZBOjpmLCBzdGQ6OmRlY2x2YWw8QT4oKSkpIHNvbWVfdHlwZTsKCiAgICB2b2lkIGYoKTsKfTsKCnRlbXBsYXRlIDw+CmNsYXNzIEE8dm9pZD4KewogICAgdm9pZCBmKCk7CiAgICB0eXBlZGVmIGRlY2x0eXBlKHN0ZDo6YmluZCgmQTo6Ziwgc3RkOjpkZWNsdmFsPEE+KCkpKSBzb21lX3R5cGU7Cgp9OwoKCmludCBtYWluKCkKewogIHJldHVybiAwOwp9Cg==
prog.cpp:14:56: error: invalid use of incomplete type 'class A<void>'
prog.cpp:12:1: error: declaration of 'class A<void>'
prog.cpp:14:56: error: initializing argument 2 of 'std::_Bind<typename std::_Maybe_wrap_member_pointer<_Tp>::type(_ArgTypes ...)> std::bind(_Functor, _ArgTypes ...) [with _Functor = void (A<void>::*)(), _ArgTypes = {A<void>}, typename std::_Maybe_wrap_member_pointer<_Tp>::type = std::_Mem_fn<void (A<void>::*)()>]'
prog.cpp:14:56: error: invalid use of incomplete type 'class A<void>'
prog.cpp:12:1: error: declaration of 'class A<void>'
prog.cpp:14:56: error: initializing argument 2 of 'std::_Bind<typename std::_Maybe_wrap_member_pointer<_Tp>::type(_ArgTypes ...)> std::bind(_Functor, _ArgTypes ...) [with _Functor = void (A<void>::*)(), _ArgTypes = {A<void>}, typename std::_Maybe_wrap_member_pointer<_Tp>::type = std::_Mem_fn<void (A<void>::*)()>]'
-
result: Compilation error (maybe you wish to see an example for C++11)


