2007-10-29 22:13:23 +01:00
|
|
|
// Functor implementations -*- C++ -*-
|
|
|
|
|
2011-01-31 21:46:43 +01:00
|
|
|
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011
|
2007-10-29 22:13:23 +01:00
|
|
|
// Free Software Foundation, Inc.
|
|
|
|
//
|
|
|
|
// 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)
|
2007-10-29 22:13:23 +01: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.
|
2007-10-29 22:13:23 +01: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/>.
|
2007-10-29 22:13:23 +01: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** @file backward/binders.h
|
|
|
|
* This is an internal header file, included by other library headers.
|
2011-02-01 02:31:42 +01:00
|
|
|
* Do not attempt to use it directly. @headername{functional}
|
2007-10-29 22:13:23 +01:00
|
|
|
*/
|
|
|
|
|
2010-03-16 23:34:53 +01:00
|
|
|
#ifndef _BACKWARD_BINDERS_H
|
|
|
|
#define _BACKWARD_BINDERS_H 1
|
2007-10-29 22:13:23 +01:00
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
namespace std _GLIBCXX_VISIBILITY(default)
|
|
|
|
{
|
|
|
|
_GLIBCXX_BEGIN_NAMESPACE_VERSION
|
2007-10-29 22:13:23 +01:00
|
|
|
|
|
|
|
// 20.3.6 binders
|
2009-02-21 01:45:21 +01:00
|
|
|
/** @defgroup binders Binder Classes
|
2009-02-19 09:15:15 +01:00
|
|
|
* @ingroup functors
|
|
|
|
*
|
2010-02-04 19:20:34 +01:00
|
|
|
* Binders turn functions/functors with two arguments into functors
|
|
|
|
* with a single argument, storing an argument to be applied later.
|
|
|
|
* For example, a variable @c B of type @c binder1st is constructed
|
|
|
|
* from a functor @c f and an argument @c x. Later, B's @c
|
|
|
|
* operator() is called with a single argument @c y. The return
|
|
|
|
* value is the value of @c f(x,y). @c B can be @a called with
|
|
|
|
* various arguments (y1, y2, ...) and will in turn call @c
|
|
|
|
* f(x,y1), @c f(x,y2), ...
|
2007-10-29 22:13:23 +01:00
|
|
|
*
|
2010-02-04 19:20:34 +01:00
|
|
|
* The function @c bind1st is provided to save some typing. It takes the
|
2007-10-29 22:13:23 +01:00
|
|
|
* function and an argument as parameters, and returns an instance of
|
|
|
|
* @c binder1st.
|
|
|
|
*
|
|
|
|
* The type @c binder2nd and its creator function @c bind2nd do the same
|
|
|
|
* thing, but the stored argument is passed as the second parameter instead
|
2011-11-20 22:14:56 +01:00
|
|
|
* of the first, e.g., @c bind2nd(std::minus<float>(),1.3) will create a
|
2007-10-29 22:13:23 +01:00
|
|
|
* functor whose @c operator() accepts a floating-point number, subtracts
|
2010-02-04 19:20:34 +01:00
|
|
|
* 1.3 from it, and returns the result. (If @c bind1st had been used,
|
|
|
|
* the functor would perform <em>1.3 - x</em> instead.
|
2007-10-29 22:13:23 +01:00
|
|
|
*
|
|
|
|
* Creator-wrapper functions like @c bind1st are intended to be used in
|
2010-02-04 19:20:34 +01:00
|
|
|
* calling algorithms. Their return values will be temporary objects.
|
2007-10-29 22:13:23 +01:00
|
|
|
* (The goal is to not require you to type names like
|
|
|
|
* @c std::binder1st<std::plus<int>> for declaring a variable to hold the
|
2011-11-20 22:14:56 +01:00
|
|
|
* return value from @c bind1st(std::plus<int>(),5).
|
2007-10-29 22:13:23 +01:00
|
|
|
*
|
|
|
|
* These become more useful when combined with the composition functions.
|
|
|
|
*
|
2011-11-20 22:14:56 +01:00
|
|
|
* These functions are deprecated in C++11 and can be replaced by
|
|
|
|
* @c std::bind (or @c std::tr1::bind) which is more powerful and flexible,
|
|
|
|
* supporting functions with any number of arguments. Uses of @c bind1st
|
|
|
|
* can be replaced by @c std::bind(f, x, std::placeholders::_1) and
|
|
|
|
* @c bind2nd by @c std::bind(f, std::placeholders::_1, x).
|
2007-10-29 22:13:23 +01:00
|
|
|
* @{
|
|
|
|
*/
|
2009-02-21 01:45:21 +01:00
|
|
|
/// One of the @link binders binder functors@endlink.
|
2007-10-29 22:13:23 +01:00
|
|
|
template<typename _Operation>
|
|
|
|
class binder1st
|
|
|
|
: public unary_function<typename _Operation::second_argument_type,
|
|
|
|
typename _Operation::result_type>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Operation op;
|
|
|
|
typename _Operation::first_argument_type value;
|
|
|
|
|
|
|
|
public:
|
|
|
|
binder1st(const _Operation& __x,
|
|
|
|
const typename _Operation::first_argument_type& __y)
|
|
|
|
: op(__x), value(__y) { }
|
|
|
|
|
|
|
|
typename _Operation::result_type
|
|
|
|
operator()(const typename _Operation::second_argument_type& __x) const
|
|
|
|
{ return op(value, __x); }
|
|
|
|
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// 109. Missing binders for non-const sequence elements
|
|
|
|
typename _Operation::result_type
|
|
|
|
operator()(typename _Operation::second_argument_type& __x) const
|
|
|
|
{ return op(value, __x); }
|
2011-01-31 21:46:43 +01:00
|
|
|
} _GLIBCXX_DEPRECATED;
|
2007-10-29 22:13:23 +01:00
|
|
|
|
2009-02-21 01:45:21 +01:00
|
|
|
/// One of the @link binders binder functors@endlink.
|
2007-10-29 22:13:23 +01:00
|
|
|
template<typename _Operation, typename _Tp>
|
|
|
|
inline binder1st<_Operation>
|
|
|
|
bind1st(const _Operation& __fn, const _Tp& __x)
|
|
|
|
{
|
|
|
|
typedef typename _Operation::first_argument_type _Arg1_type;
|
|
|
|
return binder1st<_Operation>(__fn, _Arg1_type(__x));
|
|
|
|
}
|
|
|
|
|
2009-02-21 01:45:21 +01:00
|
|
|
/// One of the @link binders binder functors@endlink.
|
2007-10-29 22:13:23 +01:00
|
|
|
template<typename _Operation>
|
|
|
|
class binder2nd
|
|
|
|
: public unary_function<typename _Operation::first_argument_type,
|
|
|
|
typename _Operation::result_type>
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
_Operation op;
|
|
|
|
typename _Operation::second_argument_type value;
|
|
|
|
|
|
|
|
public:
|
|
|
|
binder2nd(const _Operation& __x,
|
|
|
|
const typename _Operation::second_argument_type& __y)
|
|
|
|
: op(__x), value(__y) { }
|
|
|
|
|
|
|
|
typename _Operation::result_type
|
|
|
|
operator()(const typename _Operation::first_argument_type& __x) const
|
|
|
|
{ return op(__x, value); }
|
|
|
|
|
|
|
|
// _GLIBCXX_RESOLVE_LIB_DEFECTS
|
|
|
|
// 109. Missing binders for non-const sequence elements
|
|
|
|
typename _Operation::result_type
|
|
|
|
operator()(typename _Operation::first_argument_type& __x) const
|
|
|
|
{ return op(__x, value); }
|
2011-01-31 21:46:43 +01:00
|
|
|
} _GLIBCXX_DEPRECATED;
|
2007-10-29 22:13:23 +01:00
|
|
|
|
2009-02-21 01:45:21 +01:00
|
|
|
/// One of the @link binders binder functors@endlink.
|
2007-10-29 22:13:23 +01:00
|
|
|
template<typename _Operation, typename _Tp>
|
|
|
|
inline binder2nd<_Operation>
|
|
|
|
bind2nd(const _Operation& __fn, const _Tp& __x)
|
|
|
|
{
|
|
|
|
typedef typename _Operation::second_argument_type _Arg2_type;
|
|
|
|
return binder2nd<_Operation>(__fn, _Arg2_type(__x));
|
|
|
|
}
|
|
|
|
/** @} */
|
|
|
|
|
PR libstdc++/36104 part four
2011-01-30 Benjamin Kosnik <bkoz@redhat.com>
PR libstdc++/36104 part four
* include/bits/c++config (_GLIBCXX_STD): Remove.
(_GLIBCXX_STD_D, _GLIBCXX_PR): Now _GLIBCXX_STD_C.
(_GLIBCXX_P): Now _GLIBCXX_STD_A.
(_GLIBCXX_NAMESPACE_DEBUG, _GLIBCXX_NAMESPACE_PARALLEL,
_GLIBCXX_NAMESPACE_PROFILE, _GLIBCXX_NAMESPACE_VERSION): Remove.
(_GLIBCXX_INLINE_DEBUG, _GLIBCXX_INLINE_PARALLEL,
_GLIBCXX_INLINE_PROFILE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE(X)): Remove.
(_GLIBCXX_END_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NESTED_NAMESPACE(X, Y)): Remove.
(_GLIBCXX_END_NESTED_NAMESPACE): Remove.
(_GLIBCXX_BEGIN_NAMESPACE_ALGO): Add.
(_GLIBCXX_END_NAMESPACE_ALGO): Add.
(_GLIBCXX_BEGIN_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_END_NAMESPACE_CONTAINER): Add.
(_GLIBCXX_BEGIN_NAMESPACE_VERSION): Add.
(_GLIBCXX_END_NAMESPACE_VERSION): Add.
(_GLIBCXX_BEGIN_LDBL_NAMESPACE): To _GLIBCXX_BEGIN_NAMESPACE_LDBL.
(_GLIBCXX_END_LDBL_NAMESPACE): To _GLIBCXX_END_NAMESPACE_LDBL.
(_GLIBCXX_VISIBILITY_ATTR): Revert to _GLIBCXX_VISIBILITY.
* include/*: Use new macros for namespace scope.
* config/*: Same.
* src/*: Same.
* src/Makefile.am (sources): Remove debug_list.cc, add
compatibility-debug_list-2.cc.
(parallel_sources): Remove parallel_list.cc, add
compatibility-parallel_list-2.cc.
(compatibility-parallel_list-2.[o,lo]): New rule.
* src/Makefile.in: Regenerate.
* src/debug_list.cc: Remove.
* src/parallel_list.cc: Remove.
* src/compatibility-list-2.cc: New.
* src/compatibility-debug_list-2.cc: New.
* src/compatibility-parallel_list-2.cc: New.
* doc/doxygen/user.cfg.in: Adjust macros.
* testsuite/20_util/auto_ptr/assign_neg.cc: Adjust line numbers, macros.
* testsuite/20_util/declval/requirements/1_neg.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg1.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg2.cc: Same.
* testsuite/20_util/duration/requirements/typedefs_neg3.cc: Same.
* testsuite/20_util/forward/c_neg.cc: Same.
* testsuite/20_util/forward/f_neg.cc: Same.
* testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same.
* testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Same.
* testsuite/20_util/ratio/operations/ops_overflow_neg.cc: Same.
* testsuite/20_util/shared_ptr/cons/43820_neg.cc: Same.
* testsuite/20_util/weak_ptr/comparison/cmp_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/deque/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/forward_list/capacity/1.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
assign_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/forward_list/requirements/dr438/
insert_neg.cc: Same.
* testsuite/23_containers/list/capacity/29134.cc: Same.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Same.
* testsuite/23_containers/vector/bool/capacity/29134.cc: Same.
* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Same.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc: Same.
* testsuite/25_algorithms/sort/35588.cc: Same.
* testsuite/27_io/ios_base/cons/assign_neg.cc: Same.
* testsuite/27_io/ios_base/cons/copy_neg.cc: Same.
* testsuite/ext/profile/mutex_extensions_neg.cc: Same.
* testsuite/ext/profile/profiler_algos.cc: Same.
* testsuite/ext/type_traits/add_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/add_unsigned_integer_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_floating_neg.cc: Same.
* testsuite/ext/type_traits/remove_unsigned_integer_neg.cc: Same.
* testsuite/tr1/2_general_utilities/shared_ptr/cons/43820_neg.cc: Same.
From-SVN: r169421
2011-01-30 23:39:36 +01:00
|
|
|
_GLIBCXX_END_NAMESPACE_VERSION
|
|
|
|
} // namespace
|
2007-10-29 22:13:23 +01:00
|
|
|
|
2010-03-16 23:34:53 +01:00
|
|
|
#endif /* _BACKWARD_BINDERS_H */
|