DDS  ver. 3.6
stlx.h
Go to the documentation of this file.
1 // Copyright 2014 GSI, Inc. All rights reserved.
2 //
3 // STL extensions
4 //
5 #ifndef _DDS_STLX_H_
6 #define _DDS_STLX_H_
7 
8 namespace dds::misc
9 {
15  namespace stlx
16  {
17  template <typename _T>
18  struct remove_cref
19  {
20  typedef _T type;
21  };
22 
23  template <typename _T>
24  struct remove_cref<const _T&>
25  {
26  typedef _T type;
27  };
28 
29  template <typename _Result, typename _Class, typename _Argument>
30  class mem_fun1_t : public std::binary_function<_Class*,
31  typename remove_cref<_Argument>::type, // was: Argument
32  _Result>
33  {
34  public:
35  explicit mem_fun1_t(_Result (_Class::*member)(_Argument))
36  : member_(member)
37  {
38  }
39 
40  _Result operator()(_Class* object, _Argument argument) const
41  {
42  return (object->*member_)(argument);
43  }
44 
45  private:
46  _Result (_Class::*member_)(_Argument);
47  };
54  template <typename _Result, typename _Class, typename _Argument>
55  mem_fun1_t<_Result, _Class, _Argument> mem_fun(_Result (_Class::*member)(_Argument))
56  {
58  }
59  /*
60  *
61  * @brief The select1st function object takes a single argument, a pair, and returns the pair's first element.
62  *
63  */
64  template <class _Pair>
65  struct select1st : public std::unary_function<_Pair, typename _Pair::first_type>
66  {
67  typename _Pair::first_type& operator()(_Pair& __x) const
68  {
69  return __x.first;
70  }
71  const typename _Pair::first_type& operator()(const _Pair& __x) const
72  {
73  return __x.first;
74  }
75  };
81  template <class _Pair>
82  struct select2nd : public std::unary_function<_Pair, typename _Pair::second_type>
83  {
84  typename _Pair::second_type& operator()(_Pair& __x) const
85  {
86  return __x.second;
87  }
88  const typename _Pair::second_type& operator()(const _Pair& __x) const
89  {
90  return __x.second;
91  }
92  };
93  }; // namespace stlx
94 }; // namespace dds::misc
95 #endif /*_DDS_STLX_H_*/
_Pair::second_type & operator()(_Pair &__x) const
Definition: stlx.h:84
const _Pair::second_type & operator()(const _Pair &__x) const
Definition: stlx.h:88
Definition: stlx.h:65
const _Pair::first_type & operator()(const _Pair &__x) const
Definition: stlx.h:71
#define _T(s)
Use TCHAR instead of char or wchar_t. It will be appropriately translated.
Definition: def.h:82
_T type
Definition: stlx.h:20
mem_fun1_t(_Result(_Class::*member)(_Argument))
Definition: stlx.h:35
_Pair::first_type & operator()(_Pair &__x) const
Definition: stlx.h:67
mem_fun1_t< _Result, _Class, _Argument > mem_fun(_Result(_Class::*member)(_Argument))
The mem_fun() template is a custom mem_fun adapter, which extends std::mem_fun.
Definition: stlx.h:55
Definition: stlx.h:18
_Result operator()(_Class *object, _Argument argument) const
Definition: stlx.h:40
Definition: stlx.h:30
The select2nd function object takes a single argument, a pair, and returns the pair's second element.
Definition: stlx.h:82
Definition: BoostHelper.h:14