2 // Cadenza New Zealand Ltd
4 // (C) Copyright John Maddock 2001.
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)
10 // See http://www.boost.org/libs/config for the most recent version.
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.
21 namespace boost_no_pointer_to_member_const{
23 template <class S, class T>
24 class const_mem_fun_t : public std::unary_function<const T*, S>
27 explicit const_mem_fun_t(S (T::*p)() const)
31 S operator()(const T* p) const
39 template <class S, class T, class A>
40 class const_mem_fun1_t : public std::binary_function<const T*, A, S>
43 explicit const_mem_fun1_t(S (T::*p)(A) const)
47 S operator()(const T* p, const A& x) const
55 template<class S, class T>
56 inline const_mem_fun_t<S,T> mem_fun(S (T::*f)() const)
58 return const_mem_fun_t<S,T>(f);
61 template<class S, class T, class A>
62 inline const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const)
64 return const_mem_fun1_t<S,T,A>(f);
71 int foo2(int i)const{ return i*2; }
77 boost_no_pointer_to_member_const::mem_fun(&tester::foo1);
78 boost_no_pointer_to_member_const::mem_fun(&tester::foo2);