• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//  Copyright (C) Joaquin M Lopez Munoz 2004.
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_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS
9//  TITLE:         pointers to members as template arguments
10//  DESCRIPTION:   Non-type template parameters which take pointers
11//                 to members, fail to work correctly.
12
13
14namespace boost_no_pointer_to_member_template_parameters{
15
16struct pair
17{
18   int x, y;
19
20   pair(int x_,int y_)
21      : x(x_), y(y_)
22      {}
23};
24
25template<int pair::* PtrToPairMember>
26struct foo
27{
28   int bar(pair& p)
29   {
30      return p.*PtrToPairMember;
31   }
32};
33
34int test()
35{
36   pair p(0,1);
37   foo<&pair::x> fx;
38   foo<&pair::y> fy;
39
40   if((fx.bar(p) != 0) || (fy.bar(p) != 1))
41      return 1;
42   return 0;
43}
44
45}
46
47
48
49
50
51