• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6//  See http://www.boost.org/libs/config for most recent version.
7
8//  MACRO:         BOOST_NO_MEMBER_FUNCTION_SPECIALIZATIONS
9//  TITLE:         Specialisation of individual member functions.
10//  DESCRIPTION:   Verify that specializations of individual members
11//                 of template classes work OK.
12
13
14namespace boost_no_member_function_specializations{
15
16
17template<class T>
18class foo
19{
20public:
21   foo();
22   foo(const T&);
23   ~foo();
24   int bar();
25};
26
27// declare specialisations:
28template<> foo<int>::foo();
29template<> foo<int>::foo(const int&);
30template<> foo<int>::~foo();
31template<> int foo<int>::bar();
32
33// provide defaults:
34template<class T> foo<T>::foo(){}
35template<class T> foo<T>::foo(const T&){}
36template<class T> foo<T>::~foo(){}
37template<class T> int foo<T>::bar(){ return 0; }
38
39// provide defs:
40template<> foo<int>::foo(){}
41template<> foo<int>::foo(const int&){}
42template<> foo<int>::~foo(){}
43template<> int foo<int>::bar(){ return 1; }
44
45
46int test()
47{
48   foo<double> f1;
49   foo<int> f2;
50   f1.bar();
51   f2.bar();
52   return 0;
53}
54
55
56}
57
58
59
60
61
62
63