Changeset 65dde99 in mainline
- Timestamp:
- 2018-07-05T21:41:22Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9751280
- Parents:
- 7ea90cf
- git-author:
- Dzejrou <dzejrou@…> (2018-04-28 00:32:52)
- git-committer:
- Dzejrou <dzejrou@…> (2018-07-05 21:41:22)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/cpp/include/impl/functional.hpp
r7ea90cf r65dde99 99 99 100 100 template<class T> 101 class reference_wrapper; 101 class reference_wrapper 102 { 103 public: 104 using type = T; 105 // TODO: conditional typedefs 106 107 reference_wrapper(type& val) noexcept 108 : data_{&val} 109 { /* DUMMY BODY */ } 110 111 reference_wrapper(type&&) = delete; 112 113 reference_wrapper(const reference_wrapper& other) noexcept 114 : data_{other.data_} 115 { /* DUMMY BODY */ } 116 117 reference_wrapper& operator=(const reference_wrapper& other) noexcept 118 { 119 data_ = other.data_; 120 121 return *this; 122 } 123 124 operator type&() const noexcept 125 { 126 return *data_; 127 } 128 129 type& get() const noexcept 130 { 131 return *data_; 132 } 133 134 template<class... Args> 135 result_of_t<type&(Args&&...)> operator()(Args&&... args) const 136 { 137 return invoke(*data_, std::forward<Args>(args)...); 138 } 139 140 private: 141 type* data_; 142 }; 102 143 103 144 template<class T> 104 reference_wrapper<T> ref(T& t) noexcept; 145 reference_wrapper<T> ref(T& t) noexcept 146 { 147 return reference_wrapper<T>{t}; 148 } 105 149 106 150 template<class T> 107 reference_wrapper<const T> cref(const T& t) noexcept; 151 reference_wrapper<const T> cref(const T& t) noexcept 152 { 153 return reference_wrapper<const T>{t}; 154 } 108 155 109 156 template<class T> … … 114 161 115 162 template<class T> 116 reference_wrapper<T> ref(reference_wrapper<T> ref) noexcept; 163 reference_wrapper<T> ref(reference_wrapper<T> t) noexcept 164 { 165 return ref(t.get()); 166 } 117 167 118 168 template<class T> 119 reference_wrapper<const T> cref(reference_wrapper<T> ref) noexcept; 169 reference_wrapper<const T> cref(reference_wrapper<T> t) noexcept 170 { 171 return cref(t.get()); 172 } 120 173 121 174 /**
Note:
See TracChangeset
for help on using the changeset viewer.