boost_no_mem_func_spec.ipp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // (C) Copyright John Maddock 2002.
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/config for most recent version.
  6. // MACRO: BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS
  7. // TITLE: Specialisation of individual member functions.
  8. // DESCRIPTION: Verify that specializations of individual members
  9. // of template classes work OK.
  10. namespace boost_no_member_function_specializations{
  11. template<class T>
  12. class foo
  13. {
  14. public:
  15. foo();
  16. foo(const T&);
  17. ~foo();
  18. int bar();
  19. };
  20. // declare specialisations:
  21. template<> foo<int>::foo();
  22. template<> foo<int>::foo(const int&);
  23. template<> foo<int>::~foo();
  24. template<> int foo<int>::bar();
  25. // provide defaults:
  26. template<class T> foo<T>::foo(){}
  27. template<class T> foo<T>::foo(const T&){}
  28. template<class T> foo<T>::~foo(){}
  29. template<class T> int foo<T>::bar(){ return 0; }
  30. // provide defs:
  31. template<> foo<int>::foo(){}
  32. template<> foo<int>::foo(const int&){}
  33. template<> foo<int>::~foo(){}
  34. template<> int foo<int>::bar(){ return 1; }
  35. int test()
  36. {
  37. foo<double> f1;
  38. foo<int> f2;
  39. f1.bar();
  40. f2.bar();
  41. return 0;
  42. }
  43. }