2001-06-27 19:09:53 +02:00
|
|
|
// Functor implementations -*- C++ -*-
|
|
|
|
|
2010-02-04 19:20:34 +01:00
|
|
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010
|
2007-06-18 19:22:53 +02:00
|
|
|
// Free Software Foundation, Inc.
|
2001-06-27 19:09:53 +02:00
|
|
|
//
|
|
|
|
// This file is part of the GNU ISO C++ Library. This library is free
|
|
|
|
// software; you can redistribute it and/or modify it under the
|
|
|
|
// terms of the GNU General Public License as published by the
|
2009-04-09 17:00:19 +02:00
|
|
|
// Free Software Foundation; either version 3, or (at your option)
|
2001-06-27 19:09:53 +02:00
|
|
|
// any later version.
|
|
|
|
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
// permissions described in the GCC Runtime Library Exception, version
|
|
|
|
// 3.1, as published by the Free Software Foundation.
|
2001-06-27 19:09:53 +02:00
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
// You should have received a copy of the GNU General Public License and
|
|
|
|
// a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
// <http://www.gnu.org/licenses/>.
|
2001-06-27 19:09:53 +02:00
|
|
|
|
2000-10-05 13:27:02 +02:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1994
|
|
|
|
* Hewlett-Packard Company
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute and sell this software
|
|
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
|
|
* provided that the above copyright notice appear in all copies and
|
|
|
|
* that both that copyright notice and this permission notice appear
|
|
|
|
* in supporting documentation. Hewlett-Packard Company makes no
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1996-1998
|
|
|
|
* Silicon Graphics Computer Systems, Inc.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute and sell this software
|
|
|
|
* and its documentation for any purpose is hereby granted without fee,
|
|
|
|
* provided that the above copyright notice appear in all copies and
|
|
|
|
* that both that copyright notice and this permission notice appear
|
|
|
|
* in supporting documentation. Silicon Graphics makes no
|
|
|
|
* representations about the suitability of this software for any
|
|
|
|
* purpose. It is provided "as is" without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
2010-12-19 10:21:16 +01:00
|
|
|
/** @file bits/stl_function.h
|
c_io_stdio.h: Correct grammar in comments.
2001-11-02 Phil Edwards <pme@gcc.gnu.org>
* config/io/c_io_stdio.h: Correct grammar in comments.
* docs/doxygen/Intro.3: Expand "top-level" man page.
* docs/doxygen/doxygroups.cc: New module definitions (comments).
* docs/doxygen/mainpage.doxy: Tweaks.
* docs/doxygen/run_doxygen: Update Doxygen version, massage man pages.
Add @file hooks so that headers are considered to be documented.
* include/bits/basic_ios.h, include/bits/basic_file.h,
include/bits/basic_string.h, include/bits/boost_concept_check.h,
include/bits/char_traits.h, include/bits/codecvt.h,
include/bits/concept_check.h, include/bits/cpp_type_traits.h,
include/bits/fpos.h, include/bits/gslice.h, include/bits/gslice_array.h,
include/bits/indirect_array.h, include/bits/ios_base.h,
include/bits/locale_facets.h, include/bits/localefwd.h,
include/bits/mask_array.h, include/bits/pthread_allocimpl.h,
include/bits/slice.h, include/bits/slice_array.h,
include/bits/std_algorithm.h, include/bits/std_bitset.h,
include/bits/std_complex.h, include/bits/std_deque.h,
include/bits/std_fstream.h, include/bits/std_functional.h,
include/bits/std_iomanip.h, include/bits/std_ios.h,
include/bits/std_iosfwd.h, include/bits/std_iostream.h,
include/bits/std_istream.h, include/bits/std_iterator.h,
include/bits/std_limits.h, include/bits/std_list.h,
include/bits/std_locale.h, include/bits/std_map.h,
include/bits/std_memory.h, include/bits/std_numeric.h,
include/bits/std_ostream.h, include/bits/std_queue.h,
include/bits/std_set.h, include/bits/std_sstream.h,
include/bits/std_stack.h, include/bits/std_streambuf.h,
include/bits/std_string.h, include/bits/std_utility.h,
include/bits/std_valarray.h, include/bits/std_vector.h,
include/bits/stl_algo.h, include/bits/stl_alloc.h,
include/bits/stl_bvector.h, include/bits/stl_construct.h,
include/bits/stl_deque.h, include/bits/stl_heap.h,
include/bits/stl_iterator.h, include/bits/stl_iterator_base_funcs.h,
include/bits/stl_iterator_base_types.h, include/bits/stl_list.h,
include/bits/stl_map.h, include/bits/stl_multimap.h,
include/bits/stl_multiset.h, include/bits/stl_numeric.h,
include/bits/stl_pair.h, include/bits/stl_pthread_alloc.h,
include/bits/stl_queue.h, include/bits/stl_raw_storage_iter.h,
include/bits/stl_relops.h, include/bits/stl_set.h,
include/bits/stl_stack.h, include/bits/stl_tempbuf.h,
include/bits/stl_threads.h, include/bits/stl_tree.h,
include/bits/stl_uninitialized.h, include/bits/stl_vector.h,
include/bits/stream_iterator.h, include/bits/streambuf_iterator.h,
include/bits/stringfwd.h, include/bits/type_traits.h,
include/bits/valarray_array.h, include/bits/valarray_meta.h:
Add hooks, tweak comments only.
* include/bits/stl_algobase.h (swap, min, iter_swap): Also
document these functions.
* include/bits/stl_function.h: Tweak link comments.
From-SVN: r46717
2001-11-02 18:38:11 +01:00
|
|
|
* This is an internal header file, included by other library headers.
|
2010-12-19 10:21:16 +01:00
|
|
|
* Do not attempt to use it directly. @headername{functional}
|
2000-10-05 13:27:02 +02:00
|
|
|
*/
|
|
|
|
|
2007-06-18 19:22:53 +02:00
|
|
|
#ifndef _STL_FUNCTION_H
|
|
|
|
#define _STL_FUNCTION_H 1
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2005-12-19 01:56:05 +01:00
|
|
|
_GLIBCXX_BEGIN_NAMESPACE(std)
|
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
// 20.3.1 base classes
|
2009-02-19 09:15:15 +01:00
|
|
|
/** @defgroup functors Function Objects
|
|
|
|
* @ingroup utilities
|
|
|
|
*
|
2004-02-01 18:34:44 +01:00
|
|
|
* Function objects, or @e functors, are objects with an @c operator()
|
|
|
|
* defined and accessible. They can be passed as arguments to algorithm
|
|
|
|
* templates and used in place of a function pointer. Not only is the
|
|
|
|
* resulting expressiveness of the library increased, but the generated
|
|
|
|
* code can be more efficient than what you might write by hand. When we
|
2010-02-04 19:20:34 +01:00
|
|
|
* refer to @a functors, then, generally we include function pointers in
|
2004-02-01 18:34:44 +01:00
|
|
|
* the description as well.
|
|
|
|
*
|
|
|
|
* Often, functors are only created as temporaries passed to algorithm
|
|
|
|
* calls, rather than being created as named variables.
|
|
|
|
*
|
|
|
|
* Two examples taken from the standard itself follow. To perform a
|
|
|
|
* by-element addition of two vectors @c a and @c b containing @c double,
|
|
|
|
* and put the result in @c a, use
|
|
|
|
* \code
|
|
|
|
* transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
|
|
|
|
* \endcode
|
|
|
|
* To negate every element in @c a, use
|
|
|
|
* \code
|
|
|
|
* transform(a.begin(), a.end(), a.begin(), negate<double>());
|
|
|
|
* \endcode
|
|
|
|
* The addition and negation functions will be inlined directly.
|
|
|
|
*
|
2005-06-06 11:21:07 +02:00
|
|
|
* The standard functors are derived from structs named @c unary_function
|
2004-02-01 18:34:44 +01:00
|
|
|
* and @c binary_function. These two classes contain nothing but typedefs,
|
|
|
|
* to aid in generic (template) programming. If you write your own
|
|
|
|
* functors, you might consider doing the same.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
/**
|
2009-02-19 09:15:15 +01:00
|
|
|
* This is one of the @link functors functor base classes@endlink.
|
2004-02-01 18:34:44 +01:00
|
|
|
*/
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Arg, typename _Result>
|
2004-02-01 18:34:44 +01:00
|
|
|
struct unary_function
|
|
|
|
{
|
2010-12-19 10:21:16 +01:00
|
|
|
/// @c argument_type is the type of the argument
|
|
|
|
typedef _Arg argument_type;
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2010-12-19 10:21:16 +01:00
|
|
|
/// @c result_type is the return type
|
|
|
|
typedef _Result result_type;
|
2004-02-01 18:34:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2009-02-19 09:15:15 +01:00
|
|
|
* This is one of the @link functors functor base classes@endlink.
|
2004-02-01 18:34:44 +01:00
|
|
|
*/
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Arg1, typename _Arg2, typename _Result>
|
2004-02-01 18:34:44 +01:00
|
|
|
struct binary_function
|
|
|
|
{
|
2010-12-19 10:21:16 +01:00
|
|
|
/// @c first_argument_type is the type of the first argument
|
|
|
|
typedef _Arg1 first_argument_type;
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2010-12-19 10:21:16 +01:00
|
|
|
/// @c second_argument_type is the type of the second argument
|
|
|
|
typedef _Arg2 second_argument_type;
|
|
|
|
|
|
|
|
/// @c result_type is the return type
|
|
|
|
typedef _Result result_type;
|
2004-02-08 05:46:42 +01:00
|
|
|
};
|
2004-02-01 18:34:44 +01:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
// 20.3.2 arithmetic
|
2009-02-19 09:15:15 +01:00
|
|
|
/** @defgroup arithmetic_functors Arithmetic Classes
|
|
|
|
* @ingroup functors
|
|
|
|
*
|
2007-08-22 03:26:43 +02:00
|
|
|
* Because basic math often needs to be done during an algorithm,
|
|
|
|
* the library provides functors for those operations. See the
|
2009-02-19 09:15:15 +01:00
|
|
|
* documentation for @link functors the base classes@endlink
|
2007-08-22 03:26:43 +02:00
|
|
|
* for examples of their use.
|
2004-02-01 18:34:44 +01:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link arithmetic_functors math functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct plus : public binary_function<_Tp, _Tp, _Tp>
|
2004-02-08 05:46:42 +01:00
|
|
|
{
|
2004-02-01 18:34:44 +01:00
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x + __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link arithmetic_functors math functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct minus : public binary_function<_Tp, _Tp, _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x - __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link arithmetic_functors math functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct multiplies : public binary_function<_Tp, _Tp, _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x * __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link arithmetic_functors math functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct divides : public binary_function<_Tp, _Tp, _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x / __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link arithmetic_functors math functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct modulus : public binary_function<_Tp, _Tp, _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x % __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link arithmetic_functors math functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct negate : public unary_function<_Tp, _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x) const
|
|
|
|
{ return -__x; }
|
|
|
|
};
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
// 20.3.3 comparisons
|
2009-02-19 09:15:15 +01:00
|
|
|
/** @defgroup comparison_functors Comparison Classes
|
|
|
|
* @ingroup functors
|
|
|
|
*
|
2004-02-01 18:34:44 +01:00
|
|
|
* The library provides six wrapper functors for all the basic comparisons
|
|
|
|
* in C++, like @c <.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link comparison_functors comparison functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-08 05:46:42 +01:00
|
|
|
struct equal_to : public binary_function<_Tp, _Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x == __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link comparison_functors comparison functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-08 05:46:42 +01:00
|
|
|
struct not_equal_to : public binary_function<_Tp, _Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x != __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link comparison_functors comparison functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct greater : public binary_function<_Tp, _Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x > __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link comparison_functors comparison functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct less : public binary_function<_Tp, _Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x < __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link comparison_functors comparison functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct greater_equal : public binary_function<_Tp, _Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x >= __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link comparison_functors comparison functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct less_equal : public binary_function<_Tp, _Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x <= __y; }
|
|
|
|
};
|
|
|
|
/** @} */
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
// 20.3.4 logical operations
|
2009-02-19 09:15:15 +01:00
|
|
|
/** @defgroup logical_functors Boolean Operations Classes
|
|
|
|
* @ingroup functors
|
|
|
|
*
|
2007-08-22 03:26:43 +02:00
|
|
|
* Here are wrapper functors for Boolean operations: @c &&, @c ||,
|
|
|
|
* and @c !.
|
2004-02-01 18:34:44 +01:00
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link logical_functors Boolean operations functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct logical_and : public binary_function<_Tp, _Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x && __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link logical_functors Boolean operations functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct logical_or : public binary_function<_Tp, _Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x || __y; }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link logical_functors Boolean operations functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
struct logical_not : public unary_function<_Tp, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
bool
|
|
|
|
operator()(const _Tp& __x) const
|
|
|
|
{ return !__x; }
|
|
|
|
};
|
|
|
|
/** @} */
|
|
|
|
|
2007-08-02 19:39:51 +02:00
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// DR 660. Missing Bitwise Operations.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2007-08-02 19:39:51 +02:00
|
|
|
struct bit_and : public binary_function<_Tp, _Tp, _Tp>
|
|
|
|
{
|
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x & __y; }
|
|
|
|
};
|
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2007-08-02 19:39:51 +02:00
|
|
|
struct bit_or : public binary_function<_Tp, _Tp, _Tp>
|
|
|
|
{
|
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x | __y; }
|
|
|
|
};
|
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2007-08-02 19:39:51 +02:00
|
|
|
struct bit_xor : public binary_function<_Tp, _Tp, _Tp>
|
|
|
|
{
|
|
|
|
_Tp
|
|
|
|
operator()(const _Tp& __x, const _Tp& __y) const
|
|
|
|
{ return __x ^ __y; }
|
|
|
|
};
|
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
// 20.3.5 negators
|
2009-02-19 09:15:15 +01:00
|
|
|
/** @defgroup negators Negators
|
|
|
|
* @ingroup functors
|
|
|
|
*
|
2004-02-01 18:34:44 +01:00
|
|
|
* The functions @c not1 and @c not2 each take a predicate functor
|
|
|
|
* and return an instance of @c unary_negate or
|
|
|
|
* @c binary_negate, respectively. These classes are functors whose
|
|
|
|
* @c operator() performs the stored predicate function and then returns
|
|
|
|
* the negation of the result.
|
|
|
|
*
|
|
|
|
* For example, given a vector of integers and a trivial predicate,
|
|
|
|
* \code
|
|
|
|
* struct IntGreaterThanThree
|
|
|
|
* : public std::unary_function<int, bool>
|
|
|
|
* {
|
|
|
|
* bool operator() (int x) { return x > 3; }
|
|
|
|
* };
|
2004-02-08 05:46:42 +01:00
|
|
|
*
|
2004-02-01 18:34:44 +01:00
|
|
|
* std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
|
|
|
|
* \endcode
|
|
|
|
* The call to @c find_if will locate the first index (i) of @c v for which
|
2010-02-04 19:20:34 +01:00
|
|
|
* <code>!(v[i] > 3)</code> is true.
|
2004-02-01 18:34:44 +01:00
|
|
|
*
|
|
|
|
* The not1/unary_negate combination works on predicates taking a single
|
|
|
|
* argument. The not2/binary_negate combination works on predicates which
|
|
|
|
* take two arguments.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link negators negation functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Predicate>
|
2004-02-01 18:34:44 +01:00
|
|
|
class unary_negate
|
|
|
|
: public unary_function<typename _Predicate::argument_type, bool>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Predicate _M_pred;
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
2007-09-07 05:01:53 +02:00
|
|
|
unary_negate(const _Predicate& __x) : _M_pred(__x) { }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
bool
|
|
|
|
operator()(const typename _Predicate::argument_type& __x) const
|
|
|
|
{ return !_M_pred(__x); }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link negators negation functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Predicate>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline unary_negate<_Predicate>
|
2004-02-01 18:34:44 +01:00
|
|
|
not1(const _Predicate& __pred)
|
|
|
|
{ return unary_negate<_Predicate>(__pred); }
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link negators negation functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Predicate>
|
2004-02-08 05:46:42 +01:00
|
|
|
class binary_negate
|
2004-02-01 18:34:44 +01:00
|
|
|
: public binary_function<typename _Predicate::first_argument_type,
|
2007-08-22 03:26:43 +02:00
|
|
|
typename _Predicate::second_argument_type, bool>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Predicate _M_pred;
|
2007-08-22 03:26:43 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
2007-08-22 03:26:43 +02:00
|
|
|
binary_negate(const _Predicate& __x) : _M_pred(__x) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
bool
|
2004-02-08 05:46:42 +01:00
|
|
|
operator()(const typename _Predicate::first_argument_type& __x,
|
2004-02-01 18:34:44 +01:00
|
|
|
const typename _Predicate::second_argument_type& __y) const
|
|
|
|
{ return !_M_pred(__x, __y); }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link negators negation functors@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Predicate>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline binary_negate<_Predicate>
|
2004-02-01 18:34:44 +01:00
|
|
|
not2(const _Predicate& __pred)
|
|
|
|
{ return binary_negate<_Predicate>(__pred); }
|
|
|
|
/** @} */
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
// 20.3.7 adaptors pointers functions
|
2009-02-19 09:15:15 +01:00
|
|
|
/** @defgroup pointer_adaptors Adaptors for pointers to functions
|
|
|
|
* @ingroup functors
|
|
|
|
*
|
2004-02-01 18:34:44 +01:00
|
|
|
* The advantage of function objects over pointers to functions is that
|
|
|
|
* the objects in the standard library declare nested typedefs describing
|
|
|
|
* their argument and result types with uniform names (e.g., @c result_type
|
|
|
|
* from the base classes @c unary_function and @c binary_function).
|
|
|
|
* Sometimes those typedefs are required, not just optional.
|
|
|
|
*
|
|
|
|
* Adaptors are provided to turn pointers to unary (single-argument) and
|
|
|
|
* binary (double-argument) functions into function objects. The
|
|
|
|
* long-winded functor @c pointer_to_unary_function is constructed with a
|
|
|
|
* function pointer @c f, and its @c operator() called with argument @c x
|
|
|
|
* returns @c f(x). The functor @c pointer_to_binary_function does the same
|
|
|
|
* thing, but with a double-argument @c f and @c operator().
|
|
|
|
*
|
|
|
|
* The function @c ptr_fun takes a pointer-to-function @c f and constructs
|
|
|
|
* an instance of the appropriate functor.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link pointer_adaptors adaptors for function pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Arg, typename _Result>
|
2004-02-01 18:34:44 +01:00
|
|
|
class pointer_to_unary_function : public unary_function<_Arg, _Result>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Result (*_M_ptr)(_Arg);
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
public:
|
2007-09-07 05:01:53 +02:00
|
|
|
pointer_to_unary_function() { }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
|
|
|
pointer_to_unary_function(_Result (*__x)(_Arg))
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_ptr(__x) { }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
_Result
|
|
|
|
operator()(_Arg __x) const
|
|
|
|
{ return _M_ptr(__x); }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link pointer_adaptors adaptors for function pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Arg, typename _Result>
|
2004-02-01 18:34:44 +01:00
|
|
|
inline pointer_to_unary_function<_Arg, _Result>
|
|
|
|
ptr_fun(_Result (*__x)(_Arg))
|
|
|
|
{ return pointer_to_unary_function<_Arg, _Result>(__x); }
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link pointer_adaptors adaptors for function pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Arg1, typename _Arg2, typename _Result>
|
2004-02-01 18:34:44 +01:00
|
|
|
class pointer_to_binary_function
|
2004-02-01 18:56:06 +01:00
|
|
|
: public binary_function<_Arg1, _Arg2, _Result>
|
2004-02-01 18:34:44 +01:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Result (*_M_ptr)(_Arg1, _Arg2);
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
public:
|
2007-09-07 05:01:53 +02:00
|
|
|
pointer_to_binary_function() { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
2004-02-08 05:46:42 +01:00
|
|
|
pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_ptr(__x) { }
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
_Result
|
|
|
|
operator()(_Arg1 __x, _Arg2 __y) const
|
|
|
|
{ return _M_ptr(__x, __y); }
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link pointer_adaptors adaptors for function pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Arg1, typename _Arg2, typename _Result>
|
2004-02-08 05:46:42 +01:00
|
|
|
inline pointer_to_binary_function<_Arg1, _Arg2, _Result>
|
2004-02-01 18:34:44 +01:00
|
|
|
ptr_fun(_Result (*__x)(_Arg1, _Arg2))
|
|
|
|
{ return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); }
|
|
|
|
/** @} */
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
struct _Identity : public unary_function<_Tp,_Tp>
|
|
|
|
{
|
|
|
|
_Tp&
|
|
|
|
operator()(_Tp& __x) const
|
|
|
|
{ return __x; }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
const _Tp&
|
|
|
|
operator()(const _Tp& __x) const
|
|
|
|
{ return __x; }
|
|
|
|
};
|
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Pair>
|
2004-02-01 18:34:44 +01:00
|
|
|
struct _Select1st : public unary_function<_Pair,
|
|
|
|
typename _Pair::first_type>
|
|
|
|
{
|
|
|
|
typename _Pair::first_type&
|
|
|
|
operator()(_Pair& __x) const
|
|
|
|
{ return __x.first; }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
const typename _Pair::first_type&
|
|
|
|
operator()(const _Pair& __x) const
|
|
|
|
{ return __x.first; }
|
2010-10-29 17:11:47 +02:00
|
|
|
|
|
|
|
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
|
|
|
template<typename _Pair2>
|
|
|
|
typename _Pair2::first_type&
|
|
|
|
operator()(_Pair2& __x) const
|
|
|
|
{ return __x.first; }
|
|
|
|
|
|
|
|
template<typename _Pair2>
|
|
|
|
const typename _Pair2::first_type&
|
|
|
|
operator()(const _Pair2& __x) const
|
|
|
|
{ return __x.first; }
|
|
|
|
#endif
|
2004-02-01 18:34:44 +01:00
|
|
|
};
|
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Pair>
|
2004-02-01 18:34:44 +01:00
|
|
|
struct _Select2nd : public unary_function<_Pair,
|
|
|
|
typename _Pair::second_type>
|
|
|
|
{
|
|
|
|
typename _Pair::second_type&
|
|
|
|
operator()(_Pair& __x) const
|
|
|
|
{ return __x.second; }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
const typename _Pair::second_type&
|
|
|
|
operator()(const _Pair& __x) const
|
|
|
|
{ return __x.second; }
|
|
|
|
};
|
|
|
|
|
|
|
|
// 20.3.8 adaptors pointers members
|
2009-02-19 09:15:15 +01:00
|
|
|
/** @defgroup memory_adaptors Adaptors for pointers to members
|
|
|
|
* @ingroup functors
|
|
|
|
*
|
2005-06-17 23:51:34 +02:00
|
|
|
* There are a total of 8 = 2^3 function objects in this family.
|
2004-02-01 18:34:44 +01:00
|
|
|
* (1) Member functions taking no arguments vs member functions taking
|
|
|
|
* one argument.
|
|
|
|
* (2) Call through pointer vs call through reference.
|
2005-06-17 23:51:34 +02:00
|
|
|
* (3) Const vs non-const member function.
|
2004-02-01 18:34:44 +01:00
|
|
|
*
|
|
|
|
* All of this complexity is in the function objects themselves. You can
|
|
|
|
* ignore it by using the helper function mem_fun and mem_fun_ref,
|
|
|
|
* which create whichever type of adaptor is appropriate.
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*/
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link memory_adaptors adaptors for member
|
2007-08-22 03:26:43 +02:00
|
|
|
/// pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
class mem_fun_t : public unary_function<_Tp*, _Ret>
|
|
|
|
{
|
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
|
|
|
mem_fun_t(_Ret (_Tp::*__pf)())
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_f(__pf) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
_Ret
|
|
|
|
operator()(_Tp* __p) const
|
|
|
|
{ return (__p->*_M_f)(); }
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)();
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link memory_adaptors adaptors for member
|
2007-08-22 03:26:43 +02:00
|
|
|
/// pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
class const_mem_fun_t : public unary_function<const _Tp*, _Ret>
|
|
|
|
{
|
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
|
|
|
const_mem_fun_t(_Ret (_Tp::*__pf)() const)
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_f(__pf) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
_Ret
|
|
|
|
operator()(const _Tp* __p) const
|
|
|
|
{ return (__p->*_M_f)(); }
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)() const;
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link memory_adaptors adaptors for member
|
2007-08-22 03:26:43 +02:00
|
|
|
/// pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
class mem_fun_ref_t : public unary_function<_Tp, _Ret>
|
|
|
|
{
|
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
|
|
|
mem_fun_ref_t(_Ret (_Tp::*__pf)())
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_f(__pf) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
_Ret
|
|
|
|
operator()(_Tp& __r) const
|
|
|
|
{ return (__r.*_M_f)(); }
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)();
|
|
|
|
};
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link memory_adaptors adaptors for member
|
2007-08-22 03:26:43 +02:00
|
|
|
/// pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
class const_mem_fun_ref_t : public unary_function<_Tp, _Ret>
|
|
|
|
{
|
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
|
|
|
const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_f(__pf) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
_Ret
|
|
|
|
operator()(const _Tp& __r) const
|
|
|
|
{ return (__r.*_M_f)(); }
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)() const;
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link memory_adaptors adaptors for member
|
2007-08-22 03:26:43 +02:00
|
|
|
/// pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp, typename _Arg>
|
2004-02-01 18:34:44 +01:00
|
|
|
class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret>
|
|
|
|
{
|
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
2004-02-08 05:46:42 +01:00
|
|
|
mem_fun1_t(_Ret (_Tp::*__pf)(_Arg))
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_f(__pf) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
_Ret
|
|
|
|
operator()(_Tp* __p, _Arg __x) const
|
|
|
|
{ return (__p->*_M_f)(__x); }
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)(_Arg);
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link memory_adaptors adaptors for member
|
2007-08-22 03:26:43 +02:00
|
|
|
/// pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp, typename _Arg>
|
2004-02-01 18:34:44 +01:00
|
|
|
class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret>
|
|
|
|
{
|
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
|
|
|
const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_f(__pf) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
_Ret
|
|
|
|
operator()(const _Tp* __p, _Arg __x) const
|
|
|
|
{ return (__p->*_M_f)(__x); }
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)(_Arg) const;
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link memory_adaptors adaptors for member
|
2007-08-22 03:26:43 +02:00
|
|
|
/// pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp, typename _Arg>
|
2004-02-01 18:34:44 +01:00
|
|
|
class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
|
|
|
|
{
|
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
|
|
|
mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg))
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_f(__pf) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
_Ret
|
|
|
|
operator()(_Tp& __r, _Arg __x) const
|
|
|
|
{ return (__r.*_M_f)(__x); }
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)(_Arg);
|
|
|
|
};
|
|
|
|
|
2009-02-19 09:15:15 +01:00
|
|
|
/// One of the @link memory_adaptors adaptors for member
|
2007-08-22 03:26:43 +02:00
|
|
|
/// pointers@endlink.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp, typename _Arg>
|
2004-02-01 18:34:44 +01:00
|
|
|
class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
|
|
|
|
{
|
|
|
|
public:
|
2004-02-02 17:35:09 +01:00
|
|
|
explicit
|
|
|
|
const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
|
2007-09-07 05:01:53 +02:00
|
|
|
: _M_f(__pf) { }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
_Ret
|
|
|
|
operator()(const _Tp& __r, _Arg __x) const
|
|
|
|
{ return (__r.*_M_f)(__x); }
|
2007-09-07 05:01:53 +02:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
private:
|
|
|
|
_Ret (_Tp::*_M_f)(_Arg) const;
|
|
|
|
};
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2004-02-01 18:34:44 +01:00
|
|
|
// Mem_fun adaptor helper functions. There are only two:
|
|
|
|
// mem_fun and mem_fun_ref.
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
inline mem_fun_t<_Ret, _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
mem_fun(_Ret (_Tp::*__f)())
|
2004-02-05 16:39:16 +01:00
|
|
|
{ return mem_fun_t<_Ret, _Tp>(__f); }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
inline const_mem_fun_t<_Ret, _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
mem_fun(_Ret (_Tp::*__f)() const)
|
2004-02-05 16:39:16 +01:00
|
|
|
{ return const_mem_fun_t<_Ret, _Tp>(__f); }
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
inline mem_fun_ref_t<_Ret, _Tp>
|
2004-02-08 05:46:42 +01:00
|
|
|
mem_fun_ref(_Ret (_Tp::*__f)())
|
2004-02-05 16:39:16 +01:00
|
|
|
{ return mem_fun_ref_t<_Ret, _Tp>(__f); }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp>
|
2004-02-05 16:39:16 +01:00
|
|
|
inline const_mem_fun_ref_t<_Ret, _Tp>
|
2004-02-01 18:34:44 +01:00
|
|
|
mem_fun_ref(_Ret (_Tp::*__f)() const)
|
2004-02-05 16:39:16 +01:00
|
|
|
{ return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp, typename _Arg>
|
2004-02-05 16:39:16 +01:00
|
|
|
inline mem_fun1_t<_Ret, _Tp, _Arg>
|
2004-02-01 18:34:44 +01:00
|
|
|
mem_fun(_Ret (_Tp::*__f)(_Arg))
|
2004-02-05 16:39:16 +01:00
|
|
|
{ return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp, typename _Arg>
|
2004-02-05 16:39:16 +01:00
|
|
|
inline const_mem_fun1_t<_Ret, _Tp, _Arg>
|
2004-02-01 18:34:44 +01:00
|
|
|
mem_fun(_Ret (_Tp::*__f)(_Arg) const)
|
2004-02-05 16:39:16 +01:00
|
|
|
{ return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp, typename _Arg>
|
2004-02-05 16:39:16 +01:00
|
|
|
inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
|
2004-02-01 18:34:44 +01:00
|
|
|
mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
|
2004-02-05 16:39:16 +01:00
|
|
|
{ return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
2007-09-07 05:01:53 +02:00
|
|
|
template<typename _Ret, typename _Tp, typename _Arg>
|
2004-02-05 16:39:16 +01:00
|
|
|
inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
|
2004-02-01 18:34:44 +01:00
|
|
|
mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
|
2004-02-05 16:39:16 +01:00
|
|
|
{ return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
|
2004-02-01 18:34:44 +01:00
|
|
|
|
|
|
|
/** @} */
|
2004-02-08 05:46:42 +01:00
|
|
|
|
2005-12-19 01:56:05 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE
|
2000-10-05 13:27:02 +02:00
|
|
|
|
2007-11-13 18:43:57 +01:00
|
|
|
#if !defined(__GXX_EXPERIMENTAL_CXX0X__) || _GLIBCXX_DEPRECATED
|
2007-10-29 22:13:23 +01:00
|
|
|
# include <backward/binders.h>
|
|
|
|
#endif
|
|
|
|
|
2007-06-18 19:22:53 +02:00
|
|
|
#endif /* _STL_FUNCTION_H */
|