Skip to content

Commit 2800378

Browse files
committed
Make "identity::operator()" variadic to support heterogeneous operations on containers.
1 parent a77abd0 commit 2800378

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

include/boost/move/detail/meta_utils.hpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,26 @@ struct identity
208208
{
209209
typedef T type;
210210
typedef typename add_const_lvalue_reference<T>::type reference;
211+
211212
BOOST_MOVE_FORCEINLINE reference operator()(reference t) const
212213
{ return t; }
214+
215+
//For transparent types
216+
template<class K>
217+
BOOST_MOVE_FORCEINLINE const K & operator()(const K &t) const
218+
{ return t; }
219+
};
220+
221+
//////////////////////////////////////
222+
// identity
223+
//////////////////////////////////////
224+
template <>
225+
struct identity<void>
226+
{
227+
template <class U>
228+
BOOST_MOVE_FORCEINLINE typename add_const_lvalue_reference<U>::type
229+
operator()(typename add_const_lvalue_reference<U>::type t) const
230+
{ return t; }
213231
};
214232

215233
//////////////////////////////////////

0 commit comments

Comments
 (0)