libstdc++
stl_function.h
Go to the documentation of this file.
00001 // Functor implementations -*- C++ -*-
00002 
00003 // Copyright (C) 2001-2018 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /*
00026  *
00027  * Copyright (c) 1994
00028  * Hewlett-Packard Company
00029  *
00030  * Permission to use, copy, modify, distribute and sell this software
00031  * and its documentation for any purpose is hereby granted without fee,
00032  * provided that the above copyright notice appear in all copies and
00033  * that both that copyright notice and this permission notice appear
00034  * in supporting documentation.  Hewlett-Packard Company makes no
00035  * representations about the suitability of this software for any
00036  * purpose.  It is provided "as is" without express or implied warranty.
00037  *
00038  *
00039  * Copyright (c) 1996-1998
00040  * Silicon Graphics Computer Systems, Inc.
00041  *
00042  * Permission to use, copy, modify, distribute and sell this software
00043  * and its documentation for any purpose is hereby granted without fee,
00044  * provided that the above copyright notice appear in all copies and
00045  * that both that copyright notice and this permission notice appear
00046  * in supporting documentation.  Silicon Graphics makes no
00047  * representations about the suitability of this software for any
00048  * purpose.  It is provided "as is" without express or implied warranty.
00049  */
00050 
00051 /** @file bits/stl_function.h
00052  *  This is an internal header file, included by other library headers.
00053  *  Do not attempt to use it directly. @headername{functional}
00054  */
00055 
00056 #ifndef _STL_FUNCTION_H
00057 #define _STL_FUNCTION_H 1
00058 
00059 #if __cplusplus > 201103L
00060 #include <bits/move.h>
00061 #endif
00062 
00063 namespace std _GLIBCXX_VISIBILITY(default)
00064 {
00065 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00066 
00067   // 20.3.1 base classes
00068   /** @defgroup functors Function Objects
00069    * @ingroup utilities
00070    *
00071    *  Function objects, or @e functors, are objects with an @c operator()
00072    *  defined and accessible.  They can be passed as arguments to algorithm
00073    *  templates and used in place of a function pointer.  Not only is the
00074    *  resulting expressiveness of the library increased, but the generated
00075    *  code can be more efficient than what you might write by hand.  When we
00076    *  refer to @a functors, then, generally we include function pointers in
00077    *  the description as well.
00078    *
00079    *  Often, functors are only created as temporaries passed to algorithm
00080    *  calls, rather than being created as named variables.
00081    *
00082    *  Two examples taken from the standard itself follow.  To perform a
00083    *  by-element addition of two vectors @c a and @c b containing @c double,
00084    *  and put the result in @c a, use
00085    *  \code
00086    *  transform (a.begin(), a.end(), b.begin(), a.begin(), plus<double>());
00087    *  \endcode
00088    *  To negate every element in @c a, use
00089    *  \code
00090    *  transform(a.begin(), a.end(), a.begin(), negate<double>());
00091    *  \endcode
00092    *  The addition and negation functions will be inlined directly.
00093    *
00094    *  The standard functors are derived from structs named @c unary_function
00095    *  and @c binary_function.  These two classes contain nothing but typedefs,
00096    *  to aid in generic (template) programming.  If you write your own
00097    *  functors, you might consider doing the same.
00098    *
00099    *  @{
00100    */
00101   /**
00102    *  This is one of the @link functors functor base classes@endlink.
00103    */
00104   template<typename _Arg, typename _Result>
00105     struct unary_function
00106     {
00107       /// @c argument_type is the type of the argument
00108       typedef _Arg      argument_type;   
00109 
00110       /// @c result_type is the return type
00111       typedef _Result   result_type;  
00112     };
00113 
00114   /**
00115    *  This is one of the @link functors functor base classes@endlink.
00116    */
00117   template<typename _Arg1, typename _Arg2, typename _Result>
00118     struct binary_function
00119     {
00120       /// @c first_argument_type is the type of the first argument
00121       typedef _Arg1     first_argument_type; 
00122 
00123       /// @c second_argument_type is the type of the second argument
00124       typedef _Arg2     second_argument_type;
00125 
00126       /// @c result_type is the return type
00127       typedef _Result   result_type;
00128     };
00129   /** @}  */
00130 
00131   // 20.3.2 arithmetic
00132   /** @defgroup arithmetic_functors Arithmetic Classes
00133    * @ingroup functors
00134    *
00135    *  Because basic math often needs to be done during an algorithm,
00136    *  the library provides functors for those operations.  See the
00137    *  documentation for @link functors the base classes@endlink
00138    *  for examples of their use.
00139    *
00140    *  @{
00141    */
00142 
00143 #if __cplusplus > 201103L
00144   struct __is_transparent;  // undefined
00145 
00146   template<typename _Tp = void>
00147     struct plus;
00148 
00149   template<typename _Tp = void>
00150     struct minus;
00151 
00152   template<typename _Tp = void>
00153     struct multiplies;
00154 
00155   template<typename _Tp = void>
00156     struct divides;
00157 
00158   template<typename _Tp = void>
00159     struct modulus;
00160 
00161   template<typename _Tp = void>
00162     struct negate;
00163 #endif
00164 
00165   /// One of the @link arithmetic_functors math functors@endlink.
00166   template<typename _Tp>
00167     struct plus : public binary_function<_Tp, _Tp, _Tp>
00168     {
00169       _GLIBCXX14_CONSTEXPR
00170       _Tp
00171       operator()(const _Tp& __x, const _Tp& __y) const
00172       { return __x + __y; }
00173     };
00174 
00175   /// One of the @link arithmetic_functors math functors@endlink.
00176   template<typename _Tp>
00177     struct minus : public binary_function<_Tp, _Tp, _Tp>
00178     {
00179       _GLIBCXX14_CONSTEXPR
00180       _Tp
00181       operator()(const _Tp& __x, const _Tp& __y) const
00182       { return __x - __y; }
00183     };
00184 
00185   /// One of the @link arithmetic_functors math functors@endlink.
00186   template<typename _Tp>
00187     struct multiplies : public binary_function<_Tp, _Tp, _Tp>
00188     {
00189       _GLIBCXX14_CONSTEXPR
00190       _Tp
00191       operator()(const _Tp& __x, const _Tp& __y) const
00192       { return __x * __y; }
00193     };
00194 
00195   /// One of the @link arithmetic_functors math functors@endlink.
00196   template<typename _Tp>
00197     struct divides : public binary_function<_Tp, _Tp, _Tp>
00198     {
00199       _GLIBCXX14_CONSTEXPR
00200       _Tp
00201       operator()(const _Tp& __x, const _Tp& __y) const
00202       { return __x / __y; }
00203     };
00204 
00205   /// One of the @link arithmetic_functors math functors@endlink.
00206   template<typename _Tp>
00207     struct modulus : public binary_function<_Tp, _Tp, _Tp>
00208     {
00209       _GLIBCXX14_CONSTEXPR
00210       _Tp
00211       operator()(const _Tp& __x, const _Tp& __y) const
00212       { return __x % __y; }
00213     };
00214 
00215   /// One of the @link arithmetic_functors math functors@endlink.
00216   template<typename _Tp>
00217     struct negate : public unary_function<_Tp, _Tp>
00218     {
00219       _GLIBCXX14_CONSTEXPR
00220       _Tp
00221       operator()(const _Tp& __x) const
00222       { return -__x; }
00223     };
00224 
00225 #if __cplusplus > 201103L
00226 
00227 #define __cpp_lib_transparent_operators 201510
00228 
00229   template<>
00230     struct plus<void>
00231     {
00232       template <typename _Tp, typename _Up>
00233         _GLIBCXX14_CONSTEXPR
00234         auto
00235         operator()(_Tp&& __t, _Up&& __u) const
00236         noexcept(noexcept(std::forward<_Tp>(__t) + std::forward<_Up>(__u)))
00237         -> decltype(std::forward<_Tp>(__t) + std::forward<_Up>(__u))
00238         { return std::forward<_Tp>(__t) + std::forward<_Up>(__u); }
00239 
00240       typedef __is_transparent is_transparent;
00241     };
00242 
00243   /// One of the @link arithmetic_functors math functors@endlink.
00244   template<>
00245     struct minus<void>
00246     {
00247       template <typename _Tp, typename _Up>
00248         _GLIBCXX14_CONSTEXPR
00249         auto
00250         operator()(_Tp&& __t, _Up&& __u) const
00251         noexcept(noexcept(std::forward<_Tp>(__t) - std::forward<_Up>(__u)))
00252         -> decltype(std::forward<_Tp>(__t) - std::forward<_Up>(__u))
00253         { return std::forward<_Tp>(__t) - std::forward<_Up>(__u); }
00254 
00255       typedef __is_transparent is_transparent;
00256     };
00257 
00258   /// One of the @link arithmetic_functors math functors@endlink.
00259   template<>
00260     struct multiplies<void>
00261     {
00262       template <typename _Tp, typename _Up>
00263         _GLIBCXX14_CONSTEXPR
00264         auto
00265         operator()(_Tp&& __t, _Up&& __u) const
00266         noexcept(noexcept(std::forward<_Tp>(__t) * std::forward<_Up>(__u)))
00267         -> decltype(std::forward<_Tp>(__t) * std::forward<_Up>(__u))
00268         { return std::forward<_Tp>(__t) * std::forward<_Up>(__u); }
00269 
00270       typedef __is_transparent is_transparent;
00271     };
00272 
00273   /// One of the @link arithmetic_functors math functors@endlink.
00274   template<>
00275     struct divides<void>
00276     {
00277       template <typename _Tp, typename _Up>
00278         _GLIBCXX14_CONSTEXPR
00279         auto
00280         operator()(_Tp&& __t, _Up&& __u) const
00281         noexcept(noexcept(std::forward<_Tp>(__t) / std::forward<_Up>(__u)))
00282         -> decltype(std::forward<_Tp>(__t) / std::forward<_Up>(__u))
00283         { return std::forward<_Tp>(__t) / std::forward<_Up>(__u); }
00284 
00285       typedef __is_transparent is_transparent;
00286     };
00287 
00288   /// One of the @link arithmetic_functors math functors@endlink.
00289   template<>
00290     struct modulus<void>
00291     {
00292       template <typename _Tp, typename _Up>
00293         _GLIBCXX14_CONSTEXPR
00294         auto
00295         operator()(_Tp&& __t, _Up&& __u) const
00296         noexcept(noexcept(std::forward<_Tp>(__t) % std::forward<_Up>(__u)))
00297         -> decltype(std::forward<_Tp>(__t) % std::forward<_Up>(__u))
00298         { return std::forward<_Tp>(__t) % std::forward<_Up>(__u); }
00299 
00300       typedef __is_transparent is_transparent;
00301     };
00302 
00303   /// One of the @link arithmetic_functors math functors@endlink.
00304   template<>
00305     struct negate<void>
00306     {
00307       template <typename _Tp>
00308         _GLIBCXX14_CONSTEXPR
00309         auto
00310         operator()(_Tp&& __t) const
00311         noexcept(noexcept(-std::forward<_Tp>(__t)))
00312         -> decltype(-std::forward<_Tp>(__t))
00313         { return -std::forward<_Tp>(__t); }
00314 
00315       typedef __is_transparent is_transparent;
00316     };
00317 #endif
00318   /** @}  */
00319 
00320   // 20.3.3 comparisons
00321   /** @defgroup comparison_functors Comparison Classes
00322    * @ingroup functors
00323    *
00324    *  The library provides six wrapper functors for all the basic comparisons
00325    *  in C++, like @c <.
00326    *
00327    *  @{
00328    */
00329 #if __cplusplus > 201103L
00330   template<typename _Tp = void>
00331     struct equal_to;
00332 
00333   template<typename _Tp = void>
00334     struct not_equal_to;
00335 
00336   template<typename _Tp = void>
00337     struct greater;
00338 
00339   template<typename _Tp = void>
00340     struct less;
00341 
00342   template<typename _Tp = void>
00343     struct greater_equal;
00344 
00345   template<typename _Tp = void>
00346     struct less_equal;
00347 #endif
00348 
00349   /// One of the @link comparison_functors comparison functors@endlink.
00350   template<typename _Tp>
00351     struct equal_to : public binary_function<_Tp, _Tp, bool>
00352     {
00353       _GLIBCXX14_CONSTEXPR
00354       bool
00355       operator()(const _Tp& __x, const _Tp& __y) const
00356       { return __x == __y; }
00357     };
00358 
00359   /// One of the @link comparison_functors comparison functors@endlink.
00360   template<typename _Tp>
00361     struct not_equal_to : public binary_function<_Tp, _Tp, bool>
00362     {
00363       _GLIBCXX14_CONSTEXPR
00364       bool
00365       operator()(const _Tp& __x, const _Tp& __y) const
00366       { return __x != __y; }
00367     };
00368 
00369   /// One of the @link comparison_functors comparison functors@endlink.
00370   template<typename _Tp>
00371     struct greater : public binary_function<_Tp, _Tp, bool>
00372     {
00373       _GLIBCXX14_CONSTEXPR
00374       bool
00375       operator()(const _Tp& __x, const _Tp& __y) const
00376       { return __x > __y; }
00377     };
00378 
00379   /// One of the @link comparison_functors comparison functors@endlink.
00380   template<typename _Tp>
00381     struct less : public binary_function<_Tp, _Tp, bool>
00382     {
00383       _GLIBCXX14_CONSTEXPR
00384       bool
00385       operator()(const _Tp& __x, const _Tp& __y) const
00386       { return __x < __y; }
00387     };
00388 
00389   /// One of the @link comparison_functors comparison functors@endlink.
00390   template<typename _Tp>
00391     struct greater_equal : public binary_function<_Tp, _Tp, bool>
00392     {
00393       _GLIBCXX14_CONSTEXPR
00394       bool
00395       operator()(const _Tp& __x, const _Tp& __y) const
00396       { return __x >= __y; }
00397     };
00398 
00399   /// One of the @link comparison_functors comparison functors@endlink.
00400   template<typename _Tp>
00401     struct less_equal : public binary_function<_Tp, _Tp, bool>
00402     {
00403       _GLIBCXX14_CONSTEXPR
00404       bool
00405       operator()(const _Tp& __x, const _Tp& __y) const
00406       { return __x <= __y; }
00407     };
00408 
00409   // Partial specialization of std::greater for pointers.
00410   template<typename _Tp>
00411     struct greater<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
00412     {
00413       _GLIBCXX14_CONSTEXPR bool
00414       operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
00415       {
00416         if (__builtin_constant_p (__x > __y))
00417           return __x > __y;
00418         return (__UINTPTR_TYPE__)__x > (__UINTPTR_TYPE__)__y;
00419       }
00420     };
00421 
00422   // Partial specialization of std::less for pointers.
00423   template<typename _Tp>
00424     struct less<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
00425     {
00426       _GLIBCXX14_CONSTEXPR bool
00427       operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
00428       {
00429         if (__builtin_constant_p (__x < __y))
00430           return __x < __y;
00431         return (__UINTPTR_TYPE__)__x < (__UINTPTR_TYPE__)__y;
00432       }
00433     };
00434 
00435   // Partial specialization of std::greater_equal for pointers.
00436   template<typename _Tp>
00437     struct greater_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
00438     {
00439       _GLIBCXX14_CONSTEXPR bool
00440       operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
00441       {
00442         if (__builtin_constant_p (__x >= __y))
00443           return __x >= __y;
00444         return (__UINTPTR_TYPE__)__x >= (__UINTPTR_TYPE__)__y;
00445       }
00446     };
00447 
00448   // Partial specialization of std::less_equal for pointers.
00449   template<typename _Tp>
00450     struct less_equal<_Tp*> : public binary_function<_Tp*, _Tp*, bool>
00451     {
00452       _GLIBCXX14_CONSTEXPR bool
00453       operator()(_Tp* __x, _Tp* __y) const _GLIBCXX_NOTHROW
00454       {
00455         if (__builtin_constant_p (__x <= __y))
00456           return __x <= __y;
00457         return (__UINTPTR_TYPE__)__x <= (__UINTPTR_TYPE__)__y;
00458       }
00459     };
00460 
00461 #if __cplusplus >= 201402L
00462   /// One of the @link comparison_functors comparison functors@endlink.
00463   template<>
00464     struct equal_to<void>
00465     {
00466       template <typename _Tp, typename _Up>
00467         constexpr auto
00468         operator()(_Tp&& __t, _Up&& __u) const
00469         noexcept(noexcept(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))
00470         -> decltype(std::forward<_Tp>(__t) == std::forward<_Up>(__u))
00471         { return std::forward<_Tp>(__t) == std::forward<_Up>(__u); }
00472 
00473       typedef __is_transparent is_transparent;
00474     };
00475 
00476   /// One of the @link comparison_functors comparison functors@endlink.
00477   template<>
00478     struct not_equal_to<void>
00479     {
00480       template <typename _Tp, typename _Up>
00481         constexpr auto
00482         operator()(_Tp&& __t, _Up&& __u) const
00483         noexcept(noexcept(std::forward<_Tp>(__t) != std::forward<_Up>(__u)))
00484         -> decltype(std::forward<_Tp>(__t) != std::forward<_Up>(__u))
00485         { return std::forward<_Tp>(__t) != std::forward<_Up>(__u); }
00486 
00487       typedef __is_transparent is_transparent;
00488     };
00489 
00490   /// One of the @link comparison_functors comparison functors@endlink.
00491   template<>
00492     struct greater<void>
00493     {
00494       template <typename _Tp, typename _Up>
00495         constexpr auto
00496         operator()(_Tp&& __t, _Up&& __u) const
00497         noexcept(noexcept(std::forward<_Tp>(__t) > std::forward<_Up>(__u)))
00498         -> decltype(std::forward<_Tp>(__t) > std::forward<_Up>(__u))
00499         {
00500           return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
00501                         __ptr_cmp<_Tp, _Up>{});
00502         }
00503 
00504       template<typename _Tp, typename _Up>
00505         constexpr bool
00506         operator()(_Tp* __t, _Up* __u) const noexcept
00507         { return greater<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
00508 
00509       typedef __is_transparent is_transparent;
00510 
00511     private:
00512       template <typename _Tp, typename _Up>
00513         static constexpr decltype(auto)
00514         _S_cmp(_Tp&& __t, _Up&& __u, false_type)
00515         { return std::forward<_Tp>(__t) > std::forward<_Up>(__u); }
00516 
00517       template <typename _Tp, typename _Up>
00518         static constexpr bool
00519         _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
00520         {
00521           return greater<const volatile void*>{}(
00522               static_cast<const volatile void*>(std::forward<_Tp>(__t)),
00523               static_cast<const volatile void*>(std::forward<_Up>(__u)));
00524         }
00525 
00526       // True if there is no viable operator> member function.
00527       template<typename _Tp, typename _Up, typename = void>
00528         struct __not_overloaded2 : true_type { };
00529 
00530       // False if we can call T.operator>(U)
00531       template<typename _Tp, typename _Up>
00532         struct __not_overloaded2<_Tp, _Up, __void_t<
00533           decltype(std::declval<_Tp>().operator>(std::declval<_Up>()))>>
00534         : false_type { };
00535 
00536       // True if there is no overloaded operator> for these operands.
00537       template<typename _Tp, typename _Up, typename = void>
00538         struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
00539 
00540       // False if we can call operator>(T,U)
00541       template<typename _Tp, typename _Up>
00542         struct __not_overloaded<_Tp, _Up, __void_t<
00543           decltype(operator>(std::declval<_Tp>(), std::declval<_Up>()))>>
00544         : false_type { };
00545 
00546       template<typename _Tp, typename _Up>
00547         using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
00548               is_convertible<_Tp, const volatile void*>,
00549               is_convertible<_Up, const volatile void*>>;
00550     };
00551 
00552   /// One of the @link comparison_functors comparison functors@endlink.
00553   template<>
00554     struct less<void>
00555     {
00556       template <typename _Tp, typename _Up>
00557         constexpr auto
00558         operator()(_Tp&& __t, _Up&& __u) const
00559         noexcept(noexcept(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))
00560         -> decltype(std::forward<_Tp>(__t) < std::forward<_Up>(__u))
00561         {
00562           return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
00563                         __ptr_cmp<_Tp, _Up>{});
00564         }
00565 
00566       template<typename _Tp, typename _Up>
00567         constexpr bool
00568         operator()(_Tp* __t, _Up* __u) const noexcept
00569         { return less<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
00570 
00571       typedef __is_transparent is_transparent;
00572 
00573     private:
00574       template <typename _Tp, typename _Up>
00575         static constexpr decltype(auto)
00576         _S_cmp(_Tp&& __t, _Up&& __u, false_type)
00577         { return std::forward<_Tp>(__t) < std::forward<_Up>(__u); }
00578 
00579       template <typename _Tp, typename _Up>
00580         static constexpr bool
00581         _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
00582         {
00583           return less<const volatile void*>{}(
00584               static_cast<const volatile void*>(std::forward<_Tp>(__t)),
00585               static_cast<const volatile void*>(std::forward<_Up>(__u)));
00586         }
00587 
00588       // True if there is no viable operator< member function.
00589       template<typename _Tp, typename _Up, typename = void>
00590         struct __not_overloaded2 : true_type { };
00591 
00592       // False if we can call T.operator<(U)
00593       template<typename _Tp, typename _Up>
00594         struct __not_overloaded2<_Tp, _Up, __void_t<
00595           decltype(std::declval<_Tp>().operator<(std::declval<_Up>()))>>
00596         : false_type { };
00597 
00598       // True if there is no overloaded operator< for these operands.
00599       template<typename _Tp, typename _Up, typename = void>
00600         struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
00601 
00602       // False if we can call operator<(T,U)
00603       template<typename _Tp, typename _Up>
00604         struct __not_overloaded<_Tp, _Up, __void_t<
00605           decltype(operator<(std::declval<_Tp>(), std::declval<_Up>()))>>
00606         : false_type { };
00607 
00608       template<typename _Tp, typename _Up>
00609         using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
00610               is_convertible<_Tp, const volatile void*>,
00611               is_convertible<_Up, const volatile void*>>;
00612     };
00613 
00614   /// One of the @link comparison_functors comparison functors@endlink.
00615   template<>
00616     struct greater_equal<void>
00617     {
00618       template <typename _Tp, typename _Up>
00619         constexpr auto
00620         operator()(_Tp&& __t, _Up&& __u) const
00621         noexcept(noexcept(std::forward<_Tp>(__t) >= std::forward<_Up>(__u)))
00622         -> decltype(std::forward<_Tp>(__t) >= std::forward<_Up>(__u))
00623         {
00624           return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
00625                         __ptr_cmp<_Tp, _Up>{});
00626         }
00627 
00628       template<typename _Tp, typename _Up>
00629         constexpr bool
00630         operator()(_Tp* __t, _Up* __u) const noexcept
00631         { return greater_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
00632 
00633       typedef __is_transparent is_transparent;
00634 
00635     private:
00636       template <typename _Tp, typename _Up>
00637         static constexpr decltype(auto)
00638         _S_cmp(_Tp&& __t, _Up&& __u, false_type)
00639         { return std::forward<_Tp>(__t) >= std::forward<_Up>(__u); }
00640 
00641       template <typename _Tp, typename _Up>
00642         static constexpr bool
00643         _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
00644         {
00645           return greater_equal<const volatile void*>{}(
00646               static_cast<const volatile void*>(std::forward<_Tp>(__t)),
00647               static_cast<const volatile void*>(std::forward<_Up>(__u)));
00648         }
00649 
00650       // True if there is no viable operator>= member function.
00651       template<typename _Tp, typename _Up, typename = void>
00652         struct __not_overloaded2 : true_type { };
00653 
00654       // False if we can call T.operator>=(U)
00655       template<typename _Tp, typename _Up>
00656         struct __not_overloaded2<_Tp, _Up, __void_t<
00657           decltype(std::declval<_Tp>().operator>=(std::declval<_Up>()))>>
00658         : false_type { };
00659 
00660       // True if there is no overloaded operator>= for these operands.
00661       template<typename _Tp, typename _Up, typename = void>
00662         struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
00663 
00664       // False if we can call operator>=(T,U)
00665       template<typename _Tp, typename _Up>
00666         struct __not_overloaded<_Tp, _Up, __void_t<
00667           decltype(operator>=(std::declval<_Tp>(), std::declval<_Up>()))>>
00668         : false_type { };
00669 
00670       template<typename _Tp, typename _Up>
00671         using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
00672               is_convertible<_Tp, const volatile void*>,
00673               is_convertible<_Up, const volatile void*>>;
00674     };
00675 
00676   /// One of the @link comparison_functors comparison functors@endlink.
00677   template<>
00678     struct less_equal<void>
00679     {
00680       template <typename _Tp, typename _Up>
00681         constexpr auto
00682         operator()(_Tp&& __t, _Up&& __u) const
00683         noexcept(noexcept(std::forward<_Tp>(__t) <= std::forward<_Up>(__u)))
00684         -> decltype(std::forward<_Tp>(__t) <= std::forward<_Up>(__u))
00685         {
00686           return _S_cmp(std::forward<_Tp>(__t), std::forward<_Up>(__u),
00687                         __ptr_cmp<_Tp, _Up>{});
00688         }
00689 
00690       template<typename _Tp, typename _Up>
00691         constexpr bool
00692         operator()(_Tp* __t, _Up* __u) const noexcept
00693         { return less_equal<common_type_t<_Tp*, _Up*>>{}(__t, __u); }
00694 
00695       typedef __is_transparent is_transparent;
00696 
00697     private:
00698       template <typename _Tp, typename _Up>
00699         static constexpr decltype(auto)
00700         _S_cmp(_Tp&& __t, _Up&& __u, false_type)
00701         { return std::forward<_Tp>(__t) <= std::forward<_Up>(__u); }
00702 
00703       template <typename _Tp, typename _Up>
00704         static constexpr bool
00705         _S_cmp(_Tp&& __t, _Up&& __u, true_type) noexcept
00706         {
00707           return less_equal<const volatile void*>{}(
00708               static_cast<const volatile void*>(std::forward<_Tp>(__t)),
00709               static_cast<const volatile void*>(std::forward<_Up>(__u)));
00710         }
00711 
00712       // True if there is no viable operator<= member function.
00713       template<typename _Tp, typename _Up, typename = void>
00714         struct __not_overloaded2 : true_type { };
00715 
00716       // False if we can call T.operator<=(U)
00717       template<typename _Tp, typename _Up>
00718         struct __not_overloaded2<_Tp, _Up, __void_t<
00719           decltype(std::declval<_Tp>().operator<=(std::declval<_Up>()))>>
00720         : false_type { };
00721 
00722       // True if there is no overloaded operator<= for these operands.
00723       template<typename _Tp, typename _Up, typename = void>
00724         struct __not_overloaded : __not_overloaded2<_Tp, _Up> { };
00725 
00726       // False if we can call operator<=(T,U)
00727       template<typename _Tp, typename _Up>
00728         struct __not_overloaded<_Tp, _Up, __void_t<
00729           decltype(operator<=(std::declval<_Tp>(), std::declval<_Up>()))>>
00730         : false_type { };
00731 
00732       template<typename _Tp, typename _Up>
00733         using __ptr_cmp = __and_<__not_overloaded<_Tp, _Up>,
00734               is_convertible<_Tp, const volatile void*>,
00735               is_convertible<_Up, const volatile void*>>;
00736     };
00737 #endif // C++14
00738   /** @}  */
00739 
00740   // 20.3.4 logical operations
00741   /** @defgroup logical_functors Boolean Operations Classes
00742    * @ingroup functors
00743    *
00744    *  Here are wrapper functors for Boolean operations: @c &&, @c ||,
00745    *  and @c !.
00746    *
00747    *  @{
00748    */
00749 #if __cplusplus > 201103L
00750   template<typename _Tp = void>
00751     struct logical_and;
00752 
00753   template<typename _Tp = void>
00754     struct logical_or;
00755 
00756   template<typename _Tp = void>
00757     struct logical_not;
00758 #endif
00759 
00760   /// One of the @link logical_functors Boolean operations functors@endlink.
00761   template<typename _Tp>
00762     struct logical_and : public binary_function<_Tp, _Tp, bool>
00763     {
00764       _GLIBCXX14_CONSTEXPR
00765       bool
00766       operator()(const _Tp& __x, const _Tp& __y) const
00767       { return __x && __y; }
00768     };
00769 
00770   /// One of the @link logical_functors Boolean operations functors@endlink.
00771   template<typename _Tp>
00772     struct logical_or : public binary_function<_Tp, _Tp, bool>
00773     {
00774       _GLIBCXX14_CONSTEXPR
00775       bool
00776       operator()(const _Tp& __x, const _Tp& __y) const
00777       { return __x || __y; }
00778     };
00779 
00780   /// One of the @link logical_functors Boolean operations functors@endlink.
00781   template<typename _Tp>
00782     struct logical_not : public unary_function<_Tp, bool>
00783     {
00784       _GLIBCXX14_CONSTEXPR
00785       bool
00786       operator()(const _Tp& __x) const
00787       { return !__x; }
00788     };
00789 
00790 #if __cplusplus > 201103L
00791   /// One of the @link logical_functors Boolean operations functors@endlink.
00792   template<>
00793     struct logical_and<void>
00794     {
00795       template <typename _Tp, typename _Up>
00796         _GLIBCXX14_CONSTEXPR
00797         auto
00798         operator()(_Tp&& __t, _Up&& __u) const
00799         noexcept(noexcept(std::forward<_Tp>(__t) && std::forward<_Up>(__u)))
00800         -> decltype(std::forward<_Tp>(__t) && std::forward<_Up>(__u))
00801         { return std::forward<_Tp>(__t) && std::forward<_Up>(__u); }
00802 
00803       typedef __is_transparent is_transparent;
00804     };
00805 
00806   /// One of the @link logical_functors Boolean operations functors@endlink.
00807   template<>
00808     struct logical_or<void>
00809     {
00810       template <typename _Tp, typename _Up>
00811         _GLIBCXX14_CONSTEXPR
00812         auto
00813         operator()(_Tp&& __t, _Up&& __u) const
00814         noexcept(noexcept(std::forward<_Tp>(__t) || std::forward<_Up>(__u)))
00815         -> decltype(std::forward<_Tp>(__t) || std::forward<_Up>(__u))
00816         { return std::forward<_Tp>(__t) || std::forward<_Up>(__u); }
00817 
00818       typedef __is_transparent is_transparent;
00819     };
00820 
00821   /// One of the @link logical_functors Boolean operations functors@endlink.
00822   template<>
00823     struct logical_not<void>
00824     {
00825       template <typename _Tp>
00826         _GLIBCXX14_CONSTEXPR
00827         auto
00828         operator()(_Tp&& __t) const
00829         noexcept(noexcept(!std::forward<_Tp>(__t)))
00830         -> decltype(!std::forward<_Tp>(__t))
00831         { return !std::forward<_Tp>(__t); }
00832 
00833       typedef __is_transparent is_transparent;
00834     };
00835 #endif
00836   /** @}  */
00837 
00838 #if __cplusplus > 201103L
00839   template<typename _Tp = void>
00840     struct bit_and;
00841 
00842   template<typename _Tp = void>
00843     struct bit_or;
00844 
00845   template<typename _Tp = void>
00846     struct bit_xor;
00847 
00848   template<typename _Tp = void>
00849     struct bit_not;
00850 #endif
00851 
00852   // _GLIBCXX_RESOLVE_LIB_DEFECTS
00853   // DR 660. Missing Bitwise Operations.
00854   template<typename _Tp>
00855     struct bit_and : public binary_function<_Tp, _Tp, _Tp>
00856     {
00857       _GLIBCXX14_CONSTEXPR
00858       _Tp
00859       operator()(const _Tp& __x, const _Tp& __y) const
00860       { return __x & __y; }
00861     };
00862 
00863   template<typename _Tp>
00864     struct bit_or : public binary_function<_Tp, _Tp, _Tp>
00865     {
00866       _GLIBCXX14_CONSTEXPR
00867       _Tp
00868       operator()(const _Tp& __x, const _Tp& __y) const
00869       { return __x | __y; }
00870     };
00871 
00872   template<typename _Tp>
00873     struct bit_xor : public binary_function<_Tp, _Tp, _Tp>
00874     {
00875       _GLIBCXX14_CONSTEXPR
00876       _Tp
00877       operator()(const _Tp& __x, const _Tp& __y) const
00878       { return __x ^ __y; }
00879     };
00880 
00881   template<typename _Tp>
00882     struct bit_not : public unary_function<_Tp, _Tp>
00883     {
00884     _GLIBCXX14_CONSTEXPR
00885       _Tp
00886       operator()(const _Tp& __x) const
00887       { return ~__x; }
00888     };
00889 
00890 #if __cplusplus > 201103L
00891   template <>
00892     struct bit_and<void>
00893     {
00894       template <typename _Tp, typename _Up>
00895         _GLIBCXX14_CONSTEXPR
00896         auto
00897         operator()(_Tp&& __t, _Up&& __u) const
00898         noexcept(noexcept(std::forward<_Tp>(__t) & std::forward<_Up>(__u)))
00899         -> decltype(std::forward<_Tp>(__t) & std::forward<_Up>(__u))
00900         { return std::forward<_Tp>(__t) & std::forward<_Up>(__u); }
00901 
00902       typedef __is_transparent is_transparent;
00903     };
00904 
00905   template <>
00906     struct bit_or<void>
00907     {
00908       template <typename _Tp, typename _Up>
00909         _GLIBCXX14_CONSTEXPR
00910         auto
00911         operator()(_Tp&& __t, _Up&& __u) const
00912         noexcept(noexcept(std::forward<_Tp>(__t) | std::forward<_Up>(__u)))
00913         -> decltype(std::forward<_Tp>(__t) | std::forward<_Up>(__u))
00914         { return std::forward<_Tp>(__t) | std::forward<_Up>(__u); }
00915 
00916       typedef __is_transparent is_transparent;
00917     };
00918 
00919   template <>
00920     struct bit_xor<void>
00921     {
00922       template <typename _Tp, typename _Up>
00923         _GLIBCXX14_CONSTEXPR
00924         auto
00925         operator()(_Tp&& __t, _Up&& __u) const
00926         noexcept(noexcept(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u)))
00927         -> decltype(std::forward<_Tp>(__t) ^ std::forward<_Up>(__u))
00928         { return std::forward<_Tp>(__t) ^ std::forward<_Up>(__u); }
00929 
00930       typedef __is_transparent is_transparent;
00931     };
00932 
00933   template <>
00934     struct bit_not<void>
00935     {
00936       template <typename _Tp>
00937         _GLIBCXX14_CONSTEXPR
00938         auto
00939         operator()(_Tp&& __t) const
00940         noexcept(noexcept(~std::forward<_Tp>(__t)))
00941         -> decltype(~std::forward<_Tp>(__t))
00942         { return ~std::forward<_Tp>(__t); }
00943 
00944       typedef __is_transparent is_transparent;
00945     };
00946 #endif
00947 
00948   // 20.3.5 negators
00949   /** @defgroup negators Negators
00950    * @ingroup functors
00951    *
00952    *  The functions @c not1 and @c not2 each take a predicate functor
00953    *  and return an instance of @c unary_negate or
00954    *  @c binary_negate, respectively.  These classes are functors whose
00955    *  @c operator() performs the stored predicate function and then returns
00956    *  the negation of the result.
00957    *
00958    *  For example, given a vector of integers and a trivial predicate,
00959    *  \code
00960    *  struct IntGreaterThanThree
00961    *    : public std::unary_function<int, bool>
00962    *  {
00963    *      bool operator() (int x) { return x > 3; }
00964    *  };
00965    *
00966    *  std::find_if (v.begin(), v.end(), not1(IntGreaterThanThree()));
00967    *  \endcode
00968    *  The call to @c find_if will locate the first index (i) of @c v for which
00969    *  <code>!(v[i] > 3)</code> is true.
00970    *
00971    *  The not1/unary_negate combination works on predicates taking a single
00972    *  argument.  The not2/binary_negate combination works on predicates which
00973    *  take two arguments.
00974    *
00975    *  @{
00976    */
00977   /// One of the @link negators negation functors@endlink.
00978   template<typename _Predicate>
00979     class unary_negate
00980     : public unary_function<typename _Predicate::argument_type, bool>
00981     {
00982     protected:
00983       _Predicate _M_pred;
00984 
00985     public:
00986       _GLIBCXX14_CONSTEXPR
00987       explicit
00988       unary_negate(const _Predicate& __x) : _M_pred(__x) { }
00989 
00990       _GLIBCXX14_CONSTEXPR
00991       bool
00992       operator()(const typename _Predicate::argument_type& __x) const
00993       { return !_M_pred(__x); }
00994     };
00995 
00996   /// One of the @link negators negation functors@endlink.
00997   template<typename _Predicate>
00998     _GLIBCXX14_CONSTEXPR
00999     inline unary_negate<_Predicate>
01000     not1(const _Predicate& __pred)
01001     { return unary_negate<_Predicate>(__pred); }
01002 
01003   /// One of the @link negators negation functors@endlink.
01004   template<typename _Predicate>
01005     class binary_negate
01006     : public binary_function<typename _Predicate::first_argument_type,
01007                              typename _Predicate::second_argument_type, bool>
01008     {
01009     protected:
01010       _Predicate _M_pred;
01011 
01012     public:
01013       _GLIBCXX14_CONSTEXPR
01014       explicit
01015       binary_negate(const _Predicate& __x) : _M_pred(__x) { }
01016 
01017       _GLIBCXX14_CONSTEXPR
01018       bool
01019       operator()(const typename _Predicate::first_argument_type& __x,
01020                  const typename _Predicate::second_argument_type& __y) const
01021       { return !_M_pred(__x, __y); }
01022     };
01023 
01024   /// One of the @link negators negation functors@endlink.
01025   template<typename _Predicate>
01026     _GLIBCXX14_CONSTEXPR
01027     inline binary_negate<_Predicate>
01028     not2(const _Predicate& __pred)
01029     { return binary_negate<_Predicate>(__pred); }
01030   /** @}  */
01031 
01032   // 20.3.7 adaptors pointers functions
01033   /** @defgroup pointer_adaptors Adaptors for pointers to functions
01034    * @ingroup functors
01035    *
01036    *  The advantage of function objects over pointers to functions is that
01037    *  the objects in the standard library declare nested typedefs describing
01038    *  their argument and result types with uniform names (e.g., @c result_type
01039    *  from the base classes @c unary_function and @c binary_function).
01040    *  Sometimes those typedefs are required, not just optional.
01041    *
01042    *  Adaptors are provided to turn pointers to unary (single-argument) and
01043    *  binary (double-argument) functions into function objects.  The
01044    *  long-winded functor @c pointer_to_unary_function is constructed with a
01045    *  function pointer @c f, and its @c operator() called with argument @c x
01046    *  returns @c f(x).  The functor @c pointer_to_binary_function does the same
01047    *  thing, but with a double-argument @c f and @c operator().
01048    *
01049    *  The function @c ptr_fun takes a pointer-to-function @c f and constructs
01050    *  an instance of the appropriate functor.
01051    *
01052    *  @{
01053    */
01054   /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
01055   template<typename _Arg, typename _Result>
01056     class pointer_to_unary_function : public unary_function<_Arg, _Result>
01057     {
01058     protected:
01059       _Result (*_M_ptr)(_Arg);
01060 
01061     public:
01062       pointer_to_unary_function() { }
01063 
01064       explicit
01065       pointer_to_unary_function(_Result (*__x)(_Arg))
01066       : _M_ptr(__x) { }
01067 
01068       _Result
01069       operator()(_Arg __x) const
01070       { return _M_ptr(__x); }
01071     };
01072 
01073   /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
01074   template<typename _Arg, typename _Result>
01075     inline pointer_to_unary_function<_Arg, _Result>
01076     ptr_fun(_Result (*__x)(_Arg))
01077     { return pointer_to_unary_function<_Arg, _Result>(__x); }
01078 
01079   /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
01080   template<typename _Arg1, typename _Arg2, typename _Result>
01081     class pointer_to_binary_function
01082     : public binary_function<_Arg1, _Arg2, _Result>
01083     {
01084     protected:
01085       _Result (*_M_ptr)(_Arg1, _Arg2);
01086 
01087     public:
01088       pointer_to_binary_function() { }
01089 
01090       explicit
01091       pointer_to_binary_function(_Result (*__x)(_Arg1, _Arg2))
01092       : _M_ptr(__x) { }
01093 
01094       _Result
01095       operator()(_Arg1 __x, _Arg2 __y) const
01096       { return _M_ptr(__x, __y); }
01097     };
01098 
01099   /// One of the @link pointer_adaptors adaptors for function pointers@endlink.
01100   template<typename _Arg1, typename _Arg2, typename _Result>
01101     inline pointer_to_binary_function<_Arg1, _Arg2, _Result>
01102     ptr_fun(_Result (*__x)(_Arg1, _Arg2))
01103     { return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__x); }
01104   /** @}  */
01105 
01106   template<typename _Tp>
01107     struct _Identity
01108     : public unary_function<_Tp, _Tp>
01109     {
01110       _Tp&
01111       operator()(_Tp& __x) const
01112       { return __x; }
01113 
01114       const _Tp&
01115       operator()(const _Tp& __x) const
01116       { return __x; }
01117     };
01118 
01119   // Partial specialization, avoids confusing errors in e.g. std::set<const T>.
01120   template<typename _Tp> struct _Identity<const _Tp> : _Identity<_Tp> { };
01121 
01122   template<typename _Pair>
01123     struct _Select1st
01124     : public unary_function<_Pair, typename _Pair::first_type>
01125     {
01126       typename _Pair::first_type&
01127       operator()(_Pair& __x) const
01128       { return __x.first; }
01129 
01130       const typename _Pair::first_type&
01131       operator()(const _Pair& __x) const
01132       { return __x.first; }
01133 
01134 #if __cplusplus >= 201103L
01135       template<typename _Pair2>
01136         typename _Pair2::first_type&
01137         operator()(_Pair2& __x) const
01138         { return __x.first; }
01139 
01140       template<typename _Pair2>
01141         const typename _Pair2::first_type&
01142         operator()(const _Pair2& __x) const
01143         { return __x.first; }
01144 #endif
01145     };
01146 
01147   template<typename _Pair>
01148     struct _Select2nd
01149     : public unary_function<_Pair, typename _Pair::second_type>
01150     {
01151       typename _Pair::second_type&
01152       operator()(_Pair& __x) const
01153       { return __x.second; }
01154 
01155       const typename _Pair::second_type&
01156       operator()(const _Pair& __x) const
01157       { return __x.second; }
01158     };
01159 
01160   // 20.3.8 adaptors pointers members
01161   /** @defgroup memory_adaptors Adaptors for pointers to members
01162    * @ingroup functors
01163    *
01164    *  There are a total of 8 = 2^3 function objects in this family.
01165    *   (1) Member functions taking no arguments vs member functions taking
01166    *        one argument.
01167    *   (2) Call through pointer vs call through reference.
01168    *   (3) Const vs non-const member function.
01169    *
01170    *  All of this complexity is in the function objects themselves.  You can
01171    *   ignore it by using the helper function mem_fun and mem_fun_ref,
01172    *   which create whichever type of adaptor is appropriate.
01173    *
01174    *  @{
01175    */
01176   /// One of the @link memory_adaptors adaptors for member
01177   /// pointers@endlink.
01178   template<typename _Ret, typename _Tp>
01179     class mem_fun_t : public unary_function<_Tp*, _Ret>
01180     {
01181     public:
01182       explicit
01183       mem_fun_t(_Ret (_Tp::*__pf)())
01184       : _M_f(__pf) { }
01185 
01186       _Ret
01187       operator()(_Tp* __p) const
01188       { return (__p->*_M_f)(); }
01189 
01190     private:
01191       _Ret (_Tp::*_M_f)();
01192     };
01193 
01194   /// One of the @link memory_adaptors adaptors for member
01195   /// pointers@endlink.
01196   template<typename _Ret, typename _Tp>
01197     class const_mem_fun_t : public unary_function<const _Tp*, _Ret>
01198     {
01199     public:
01200       explicit
01201       const_mem_fun_t(_Ret (_Tp::*__pf)() const)
01202       : _M_f(__pf) { }
01203 
01204       _Ret
01205       operator()(const _Tp* __p) const
01206       { return (__p->*_M_f)(); }
01207 
01208     private:
01209       _Ret (_Tp::*_M_f)() const;
01210     };
01211 
01212   /// One of the @link memory_adaptors adaptors for member
01213   /// pointers@endlink.
01214   template<typename _Ret, typename _Tp>
01215     class mem_fun_ref_t : public unary_function<_Tp, _Ret>
01216     {
01217     public:
01218       explicit
01219       mem_fun_ref_t(_Ret (_Tp::*__pf)())
01220       : _M_f(__pf) { }
01221 
01222       _Ret
01223       operator()(_Tp& __r) const
01224       { return (__r.*_M_f)(); }
01225 
01226     private:
01227       _Ret (_Tp::*_M_f)();
01228   };
01229 
01230   /// One of the @link memory_adaptors adaptors for member
01231   /// pointers@endlink.
01232   template<typename _Ret, typename _Tp>
01233     class const_mem_fun_ref_t : public unary_function<_Tp, _Ret>
01234     {
01235     public:
01236       explicit
01237       const_mem_fun_ref_t(_Ret (_Tp::*__pf)() const)
01238       : _M_f(__pf) { }
01239 
01240       _Ret
01241       operator()(const _Tp& __r) const
01242       { return (__r.*_M_f)(); }
01243 
01244     private:
01245       _Ret (_Tp::*_M_f)() const;
01246     };
01247 
01248   /// One of the @link memory_adaptors adaptors for member
01249   /// pointers@endlink.
01250   template<typename _Ret, typename _Tp, typename _Arg>
01251     class mem_fun1_t : public binary_function<_Tp*, _Arg, _Ret>
01252     {
01253     public:
01254       explicit
01255       mem_fun1_t(_Ret (_Tp::*__pf)(_Arg))
01256       : _M_f(__pf) { }
01257 
01258       _Ret
01259       operator()(_Tp* __p, _Arg __x) const
01260       { return (__p->*_M_f)(__x); }
01261 
01262     private:
01263       _Ret (_Tp::*_M_f)(_Arg);
01264     };
01265 
01266   /// One of the @link memory_adaptors adaptors for member
01267   /// pointers@endlink.
01268   template<typename _Ret, typename _Tp, typename _Arg>
01269     class const_mem_fun1_t : public binary_function<const _Tp*, _Arg, _Ret>
01270     {
01271     public:
01272       explicit
01273       const_mem_fun1_t(_Ret (_Tp::*__pf)(_Arg) const)
01274       : _M_f(__pf) { }
01275 
01276       _Ret
01277       operator()(const _Tp* __p, _Arg __x) const
01278       { return (__p->*_M_f)(__x); }
01279 
01280     private:
01281       _Ret (_Tp::*_M_f)(_Arg) const;
01282     };
01283 
01284   /// One of the @link memory_adaptors adaptors for member
01285   /// pointers@endlink.
01286   template<typename _Ret, typename _Tp, typename _Arg>
01287     class mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
01288     {
01289     public:
01290       explicit
01291       mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg))
01292       : _M_f(__pf) { }
01293 
01294       _Ret
01295       operator()(_Tp& __r, _Arg __x) const
01296       { return (__r.*_M_f)(__x); }
01297 
01298     private:
01299       _Ret (_Tp::*_M_f)(_Arg);
01300     };
01301 
01302   /// One of the @link memory_adaptors adaptors for member
01303   /// pointers@endlink.
01304   template<typename _Ret, typename _Tp, typename _Arg>
01305     class const_mem_fun1_ref_t : public binary_function<_Tp, _Arg, _Ret>
01306     {
01307     public:
01308       explicit
01309       const_mem_fun1_ref_t(_Ret (_Tp::*__pf)(_Arg) const)
01310       : _M_f(__pf) { }
01311 
01312       _Ret
01313       operator()(const _Tp& __r, _Arg __x) const
01314       { return (__r.*_M_f)(__x); }
01315 
01316     private:
01317       _Ret (_Tp::*_M_f)(_Arg) const;
01318     };
01319 
01320   // Mem_fun adaptor helper functions.  There are only two:
01321   // mem_fun and mem_fun_ref.
01322   template<typename _Ret, typename _Tp>
01323     inline mem_fun_t<_Ret, _Tp>
01324     mem_fun(_Ret (_Tp::*__f)())
01325     { return mem_fun_t<_Ret, _Tp>(__f); }
01326 
01327   template<typename _Ret, typename _Tp>
01328     inline const_mem_fun_t<_Ret, _Tp>
01329     mem_fun(_Ret (_Tp::*__f)() const)
01330     { return const_mem_fun_t<_Ret, _Tp>(__f); }
01331 
01332   template<typename _Ret, typename _Tp>
01333     inline mem_fun_ref_t<_Ret, _Tp>
01334     mem_fun_ref(_Ret (_Tp::*__f)())
01335     { return mem_fun_ref_t<_Ret, _Tp>(__f); }
01336 
01337   template<typename _Ret, typename _Tp>
01338     inline const_mem_fun_ref_t<_Ret, _Tp>
01339     mem_fun_ref(_Ret (_Tp::*__f)() const)
01340     { return const_mem_fun_ref_t<_Ret, _Tp>(__f); }
01341 
01342   template<typename _Ret, typename _Tp, typename _Arg>
01343     inline mem_fun1_t<_Ret, _Tp, _Arg>
01344     mem_fun(_Ret (_Tp::*__f)(_Arg))
01345     { return mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
01346 
01347   template<typename _Ret, typename _Tp, typename _Arg>
01348     inline const_mem_fun1_t<_Ret, _Tp, _Arg>
01349     mem_fun(_Ret (_Tp::*__f)(_Arg) const)
01350     { return const_mem_fun1_t<_Ret, _Tp, _Arg>(__f); }
01351 
01352   template<typename _Ret, typename _Tp, typename _Arg>
01353     inline mem_fun1_ref_t<_Ret, _Tp, _Arg>
01354     mem_fun_ref(_Ret (_Tp::*__f)(_Arg))
01355     { return mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
01356 
01357   template<typename _Ret, typename _Tp, typename _Arg>
01358     inline const_mem_fun1_ref_t<_Ret, _Tp, _Arg>
01359     mem_fun_ref(_Ret (_Tp::*__f)(_Arg) const)
01360     { return const_mem_fun1_ref_t<_Ret, _Tp, _Arg>(__f); }
01361 
01362   /** @}  */
01363 
01364 _GLIBCXX_END_NAMESPACE_VERSION
01365 } // namespace
01366 
01367 #if (__cplusplus < 201103L) || _GLIBCXX_USE_DEPRECATED
01368 # include <backward/binders.h>
01369 #endif
01370 
01371 #endif /* _STL_FUNCTION_H */