boost_no_mem_tem_pnts.ipp 975 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. // See http://www.boost.org/libs/config for most recent version.
  6. // MACRO: BOOST_NO_POINTER_TO_MEMBER_TEMPLATE_PARAMETERS
  7. // TITLE: pointers to members as template arguments
  8. // DESCRIPTION: Non-type template parameters which take pointers
  9. // to members, fail to work correctly.
  10. namespace boost_no_pointer_to_member_template_parameters{
  11. struct pair
  12. {
  13. int x, y;
  14. pair(int x_,int y_)
  15. : x(x_), y(y_)
  16. {}
  17. };
  18. template<int pair::* PtrToPairMember>
  19. struct foo
  20. {
  21. int bar(pair& p)
  22. {
  23. return p.*PtrToPairMember;
  24. }
  25. };
  26. int test()
  27. {
  28. pair p(0,1);
  29. foo<&pair::x> fx;
  30. foo<&pair::y> fy;
  31. if((fx.bar(p) != 0) || (fy.bar(p) != 1))
  32. return 1;
  33. return 0;
  34. }
  35. }