⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functional

📁 Mac OS X 10.4.9 for x86 Source Code gcc 实现源代码
💻
📖 第 1 页 / 共 3 页
字号:
    { return cref(__t.get()); }   template<typename _Tp, bool>     struct _Mem_fn_const_or_non     {       typedef const _Tp& type;     };    template<typename _Tp>      struct _Mem_fn_const_or_non<_Tp, false>      {        typedef _Tp& type;      };  template<typename _Res, typename _Class>  class _Mem_fn<_Res _Class::*>  {    // This bit of genius is due to Peter Dimov, improved slightly by    // Douglas Gregor.    template<typename _Tp>      _Res&      _M_call(_Tp& __object, _Class *) const      { return __object.*__pm; }    template<typename _Tp, typename _Up>      _Res&      _M_call(_Tp& __object, _Up * const *) const      { return (*__object).*__pm; }    template<typename _Tp, typename _Up>      const _Res&      _M_call(_Tp& __object, const _Up * const *) const      { return (*__object).*__pm; }    template<typename _Tp>      const _Res&      _M_call(_Tp& __object, const _Class *) const      { return __object.*__pm; }    template<typename _Tp>      const _Res&      _M_call(_Tp& __ptr, const volatile void*) const      { return (*__ptr).*__pm; }    template<typename _Tp> static _Tp& __get_ref();    template<typename _Tp>      static __sfinae_types::__one __check_const(_Tp&, _Class*);    template<typename _Tp, typename _Up>      static __sfinae_types::__one __check_const(_Tp&, _Up * const *);    template<typename _Tp, typename _Up>      static __sfinae_types::__two __check_const(_Tp&, const _Up * const *);    template<typename _Tp>      static __sfinae_types::__two __check_const(_Tp&, const _Class*);    template<typename _Tp>      static __sfinae_types::__two __check_const(_Tp&, const volatile void*);  public:    template<typename _Tp>      struct _Result_type        : _Mem_fn_const_or_non<            _Res,            (sizeof(__sfinae_types::__two)             == sizeof(__check_const<_Tp>(__get_ref<_Tp>(), (_Tp*)0)))>      { };    template<typename _Signature>      struct result;    template<typename _CVMem, typename _Tp>      struct result<_CVMem(_Tp)>        : public _Result_type<_Tp> { };    template<typename _CVMem, typename _Tp>      struct result<_CVMem(_Tp&)>        : public _Result_type<_Tp> { };    explicit _Mem_fn(_Res _Class::*__pm) : __pm(__pm) { }    // Handle objects    _Res&       operator()(_Class& __object)       const    { return __object.*__pm; }    const _Res& operator()(const _Class& __object) const    { return __object.*__pm; }    // Handle pointers    _Res&       operator()(_Class* __object)       const    { return __object->*__pm; }    const _Res&    operator()(const _Class* __object) const    { return __object->*__pm; }    // Handle smart pointers and derived    template<typename _Tp>      typename _Result_type<_Tp>::type      operator()(_Tp& __unknown) const      { return _M_call(__unknown, &__unknown); }  private:    _Res _Class::*__pm;  };  /**   *  @brief Returns a function object that forwards to the member   *  pointer @a pm.   */  template<typename _Tp, typename _Class>    inline _Mem_fn<_Tp _Class::*>    mem_fn(_Tp _Class::* __pm)    {      return _Mem_fn<_Tp _Class::*>(__pm);    }  /**   *  @brief Determines if the given type _Tp is a function object   *  should be treated as a subexpression when evaluating calls to   *  function objects returned by bind(). [TR1 3.6.1]   */  template<typename _Tp>    struct is_bind_expression    {      static const bool value = false;    };  /**   *  @brief Determines if the given type _Tp is a placeholder in a   *  bind() expression and, if so, which placeholder it is. [TR1 3.6.2]   */  template<typename _Tp>    struct is_placeholder    {      static const int value = 0;    };  /**   *  @if maint   *  The type of placeholder objects defined by libstdc++.   *  @endif   */  template<int _Num> struct _Placeholder { };  /**   *  @if maint   *  Partial specialization of is_placeholder that provides the placeholder   *  number for the placeholder objects defined by libstdc++.   *  @endif   */  template<int _Num>    struct is_placeholder<_Placeholder<_Num> >    {      static const int value = _Num;    };  /**   *  @if maint   *  Maps an argument to bind() into an actual argument to the bound   *  function object [TR1 3.6.3/5]. Only the first parameter should   *  be specified: the rest are used to determine among the various   *  implementations. Note that, although this class is a function   *  object, isn't not entirely normal because it takes only two   *  parameters regardless of the number of parameters passed to the   *  bind expression. The first parameter is the bound argument and   *  the second parameter is a tuple containing references to the   *  rest of the arguments.   *  @endif   */  template<typename _Arg,           bool _IsBindExp = is_bind_expression<_Arg>::value,           bool _IsPlaceholder = (is_placeholder<_Arg>::value > 0)>    class _Mu;  /**   *  @if maint   *  If the argument is reference_wrapper<_Tp>, returns the   *  underlying reference. [TR1 3.6.3/5 bullet 1]   *  @endif   */  template<typename _Tp>    class _Mu<reference_wrapper<_Tp>, false, false>    {    public:      typedef _Tp& result_type;      /* Note: This won't actually work for const volatile       * reference_wrappers, because reference_wrapper::get() is const       * but not volatile-qualified. This might be a defect in the TR.       */      template<typename _CVRef, typename _Tuple>      result_type      operator()(_CVRef& __arg, const _Tuple&) const volatile      { return __arg.get(); }    };  /**   *  @if maint   *  If the argument is a bind expression, we invoke the underlying   *  function object with the same cv-qualifiers as we are given and   *  pass along all of our arguments (unwrapped). [TR1 3.6.3/5 bullet 2]   *  @endif   */  template<typename _Arg>    class _Mu<_Arg, true, false>    {    public:      template<typename _Signature> class result;#define _GLIBCXX_REPEAT_HEADER <tr1/mu_iterate.h>#  include <tr1/repeat.h>#undef _GLIBCXX_REPEAT_HEADER    };  /**   *  @if maint   *  If the argument is a placeholder for the Nth argument, returns   *  a reference to the Nth argument to the bind function object.   *  [TR1 3.6.3/5 bullet 3]   *  @endif   */  template<typename _Arg>    class _Mu<_Arg, false, true>    {    public:      template<typename _Signature> class result;      template<typename _CVMu, typename _CVArg, typename _Tuple>      class result<_CVMu(_CVArg, _Tuple)>      {        // Add a reference, if it hasn't already been done for us.        // This allows us to be a little bit sloppy in constructing        // the tuple that we pass to result_of<...>.        typedef typename tuple_element<(is_placeholder<_Arg>::value - 1),                                       _Tuple>::type __base_type;      public:        typedef typename add_reference<__base_type>::type type;      };      template<typename _Tuple>      typename result<_Mu(_Arg, _Tuple)>::type      operator()(const volatile _Arg&, const _Tuple& __tuple) const volatile      {        return ::std::tr1::get<(is_placeholder<_Arg>::value - 1)>(__tuple);      }    };  /**   *  @if maint   *  If the argument is just a value, returns a reference to that   *  value. The cv-qualifiers on the reference are the same as the   *  cv-qualifiers on the _Mu object. [TR1 3.6.3/5 bullet 4]   *  @endif   */  template<typename _Arg>    class _Mu<_Arg, false, false>    {    public:      template<typename _Signature> struct result;      template<typename _CVMu, typename _CVArg, typename _Tuple>      struct result<_CVMu(_CVArg, _Tuple)>      {        typedef typename add_reference<_CVArg>::type type;      };      // Pick up the cv-qualifiers of the argument      template<typename _CVArg, typename _Tuple>      _CVArg& operator()(_CVArg& __arg, const _Tuple&) const volatile      { return __arg; }    };  /**   *  @if maint   *  Maps member pointers into instances of _Mem_fn but leaves all   *  other function objects untouched. Used by tr1::bind(). The   *  primary template handles the non--member-pointer case.   *  @endif   */  template<typename _Tp>    struct _Maybe_wrap_member_pointer    {      typedef _Tp type;      static const _Tp& __do_wrap(const _Tp& __x) { return __x; }    };  /**   *  @if maint   *  Maps member pointers into instances of _Mem_fn but leaves all   *  other function objects untouched. Used by tr1::bind(). This   *  partial specialization handles the member pointer case.   *  @endif   */  template<typename _Tp, typename _Class>    struct _Maybe_wrap_member_pointer<_Tp _Class::*>    {      typedef _Mem_fn<_Tp _Class::*> type;      static type __do_wrap(_Tp _Class::* __pm) { return type(__pm); }    };  /**   *  @if maint   *  Type of the function object returned from bind().   *  @endif   */   template<typename _Signature>     struct _Bind;  /**   *  @if maint   *  Type of the function object returned from bind<R>().   *  @endif   */   template<typename _Result, typename _Signature>     struct _Bind_result;  /**   *  @if maint   *  Class template _Bind is always a bind expression.   *  @endif   */   template<typename _Signature>    struct is_bind_expression<_Bind<_Signature> >    {      static const bool value = true;    };  /**   *  @if maint   *  Class template _Bind_result is always a bind expression.   *  @endif   */   template<typename _Result, typename _Signature>   struct is_bind_expression<_Bind_result<_Result, _Signature> >    {      static const bool value = true;    };  /**   *  @brief Exception class thrown when class template function's   *  operator() is called with an empty target.   *   */  class bad_function_call : public std::exception { };  /**   *  @if maint   *  The integral constant expression 0 can be converted into a   *  pointer to this type. It is used by the function template to   *  accept NULL pointers.   *  @endif   */  struct _M_clear_type;  /**   *  @if maint   *  Trait identifying "location-invariant" types, meaning that the   *  address of the object (or any of its members) will not escape.   *  Also implies a trivial copy constructor and assignment operator.   *   @endif   */  template<typename _Tp>    struct __is_location_invariant    : integral_constant<bool,                        (is_pointer<_Tp>::value                         || is_member_pointer<_Tp>::value)>    {    };  class _Undefined_class;  union _Nocopy_types  {    void*       _M_object;    const void* _M_const_object;    void (*_M_function_pointer)();    void (_Undefined_class::*_M_member_pointer)();  };  union _Any_data {    void*       _M_access()       { return &_M_pod_data[0]; }    const void* _M_access() const { return &_M_pod_data[0]; }    template<typename _Tp> _Tp& _M_access()    { return *static_cast<_Tp*>(_M_access()); }    template<typename _Tp> const _Tp& _M_access() const    { return *static_cast<const _Tp*>(_M_access()); }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -