]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/config/test/boost_no_ptr_mem_const.ipp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / config / test / boost_no_ptr_mem_const.ipp
CommitLineData
7c673cae
FG
1// Copyright (c) 2000
2// Cadenza New Zealand Ltd
3//
4// (C) Copyright John Maddock 2001.
5//
6// Use, modification and distribution are subject to the
7// Boost Software License, Version 1.0. (See accompanying file
8// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
10// See http://www.boost.org/libs/config for the most recent version.
11
12// MACRO: BOOST_NO_POINTER_TO_MEMBER_CONST
13// TITLE: pointers to const member functions
14// DESCRIPTION: The compiler does not correctly handle
15// pointers to const member functions, preventing use
16// of these in overloaded function templates.
17// See boost/functional.hpp for example.
18
7c673cae
FG
19namespace boost_no_pointer_to_member_const{
20
21template <class S, class T>
b32b8144 22class const_mem_fun_t
7c673cae
FG
23{
24public:
25 explicit const_mem_fun_t(S (T::*p)() const)
26 :
27 ptr(p)
28 {}
29 S operator()(const T* p) const
30 {
31 return (p->*ptr)();
32 }
33private:
34 S (T::*ptr)() const;
35};
36
37template <class S, class T, class A>
b32b8144 38class const_mem_fun1_t
7c673cae
FG
39{
40public:
41 explicit const_mem_fun1_t(S (T::*p)(A) const)
42 :
43 ptr(p)
44 {}
45 S operator()(const T* p, const A& x) const
46 {
47 return (p->*ptr)(x);
48 }
49private:
50 S (T::*ptr)(A) const;
51};
52
53template<class S, class T>
54inline const_mem_fun_t<S,T> mem_fun(S (T::*f)() const)
55{
56 return const_mem_fun_t<S,T>(f);
57}
58
59template<class S, class T, class A>
60inline const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const)
61{
62 return const_mem_fun1_t<S,T,A>(f);
63}
64
65class tester
66{
67public:
68 void foo1()const{}
69 int foo2(int i)const{ return i*2; }
70};
71
72
73int test()
74{
75 boost_no_pointer_to_member_const::mem_fun(&tester::foo1);
76 boost_no_pointer_to_member_const::mem_fun(&tester::foo2);
77 return 0;
78}
79
80}
81
82
83
84