Commit 4ff1d8b4 authored by Dominik Charousset's avatar Dominik Charousset

Replace `rm_const_and_ref` with `std::decay`

parent 66f02557
...@@ -121,11 +121,11 @@ compound_member(C& (Parent::*getter)(), const Ts&... args) { ...@@ -121,11 +121,11 @@ compound_member(C& (Parent::*getter)(), const Ts&... args) {
template <class Parent, class GRes, class SRes, class SArg, class... Ts> template <class Parent, class GRes, class SRes, class SArg, class... Ts>
std::pair<std::pair<GRes (Parent::*)() const, SRes (Parent::*)(SArg)>, std::pair<std::pair<GRes (Parent::*)() const, SRes (Parent::*)(SArg)>,
detail::abstract_uniform_type_info< detail::abstract_uniform_type_info<
typename detail::rm_const_and_ref<GRes>::type>*> typename std::decay<GRes>::type>*>
compound_member(const std::pair<GRes (Parent::*)() const, compound_member(const std::pair<GRes (Parent::*)() const,
SRes (Parent::*)(SArg)>& gspair, SRes (Parent::*)(SArg)>& gspair,
const Ts&... args) { const Ts&... args) {
using mtype = typename detail::rm_const_and_ref<GRes>::type; using mtype = typename std::decay<GRes>::type;
return {gspair, new detail::default_uniform_type_info<mtype>(args...)}; return {gspair, new detail::default_uniform_type_info<mtype>(args...)};
} }
......
...@@ -432,7 +432,7 @@ template <class C, typename GRes, typename SRes, typename SArg> ...@@ -432,7 +432,7 @@ template <class C, typename GRes, typename SRes, typename SArg>
uniform_type_info_ptr new_member_tinfo(GRes (C::*getter)() const, uniform_type_info_ptr new_member_tinfo(GRes (C::*getter)() const,
SRes (C::*setter)(SArg)) { SRes (C::*setter)(SArg)) {
using access_policy = getter_setter_access_policy<C, GRes, SRes, SArg>; using access_policy = getter_setter_access_policy<C, GRes, SRes, SArg>;
using value_type = typename detail::rm_const_and_ref<GRes>::type; using value_type = typename std::decay<GRes>::type;
using result_type = member_tinfo<value_type, access_policy>; using result_type = member_tinfo<value_type, access_policy>;
return uniform_type_info_ptr( return uniform_type_info_ptr(
new result_type(access_policy(getter, setter))); new result_type(access_policy(getter, setter)));
...@@ -443,7 +443,7 @@ uniform_type_info_ptr new_member_tinfo(GRes (C::*getter)() const, ...@@ -443,7 +443,7 @@ uniform_type_info_ptr new_member_tinfo(GRes (C::*getter)() const,
SRes (C::*setter)(SArg), SRes (C::*setter)(SArg),
uniform_type_info_ptr meminf) { uniform_type_info_ptr meminf) {
using access_policy = getter_setter_access_policy<C, GRes, SRes, SArg>; using access_policy = getter_setter_access_policy<C, GRes, SRes, SArg>;
using value_type = typename detail::rm_const_and_ref<GRes>::type; using value_type = typename std::decay<GRes>::type;
using tinfo = member_tinfo<value_type, access_policy, using tinfo = member_tinfo<value_type, access_policy,
forwarding_serialize_policy>; forwarding_serialize_policy>;
return uniform_type_info_ptr(new tinfo(access_policy(getter, setter), return uniform_type_info_ptr(new tinfo(access_policy(getter, setter),
...@@ -538,7 +538,7 @@ class default_uniform_type_info : public detail::abstract_uniform_type_info<T> { ...@@ -538,7 +538,7 @@ class default_uniform_type_info : public detail::abstract_uniform_type_info<T> {
SR (C::*)(ST) // setter with one argument SR (C::*)(ST) // setter with one argument
>, >,
detail::abstract_uniform_type_info< detail::abstract_uniform_type_info<
typename detail::rm_const_and_ref<GR>::type>*>& pr, typename std::decay<GR>::type>*>& pr,
Ts&&... args) { Ts&&... args) {
m_members.push_back(new_member_tinfo(pr.first.first, pr.first.second, m_members.push_back(new_member_tinfo(pr.first.first, pr.first.second,
uniform_type_info_ptr(pr.second))); uniform_type_info_ptr(pr.second)));
......
...@@ -64,7 +64,7 @@ template <class T> ...@@ -64,7 +64,7 @@ template <class T>
struct strip_and_convert { struct strip_and_convert {
using type = using type =
typename implicit_conversions< typename implicit_conversions<
typename rm_const_and_ref<T>::type typename std::decay<T>::type
>::type; >::type;
}; };
......
...@@ -49,7 +49,7 @@ template <class T> ...@@ -49,7 +49,7 @@ template <class T>
struct purge_refs { struct purge_refs {
using type = using type =
typename purge_refs_impl< typename purge_refs_impl<
typename detail::rm_const_and_ref<T>::type typename std::decay<T>::type
>::type; >::type;
}; };
......
...@@ -33,31 +33,6 @@ ...@@ -33,31 +33,6 @@
namespace caf { namespace caf {
namespace detail { namespace detail {
/**
* Equal to std::remove_const<std::remove_reference<T>::type>.
*/
template <class T>
struct rm_const_and_ref {
using type = T;
};
template <class T>
struct rm_const_and_ref<const T&> {
using type = T;
};
template <class T>
struct rm_const_and_ref<const T> {
using type = T;
};
template <class T>
struct rm_const_and_ref<T&> {
using type = T;
};
// template <> struct rm_const_and_ref<void> { };
/** /**
* Joins all bool constants using operator &&. * Joins all bool constants using operator &&.
*/ */
...@@ -117,17 +92,17 @@ struct is_array_of { ...@@ -117,17 +92,17 @@ struct is_array_of {
*/ */
template <class T0, typename T1> template <class T0, typename T1>
struct deduce_ref_type { struct deduce_ref_type {
using type = typename detail::rm_const_and_ref<T1>::type; using type = typename std::decay<T1>::type;
}; };
template <class T0, typename T1> template <class T0, typename T1>
struct deduce_ref_type<T0&, T1> { struct deduce_ref_type<T0&, T1> {
using type = typename detail::rm_const_and_ref<T1>::type&; using type = typename std::decay<T1>::type&;
}; };
template <class T0, typename T1> template <class T0, typename T1>
struct deduce_ref_type<const T0&, T1> { struct deduce_ref_type<const T0&, T1> {
using type = const typename detail::rm_const_and_ref<T1>::type&; using type = const typename std::decay<T1>::type&;
}; };
/** /**
...@@ -210,7 +185,7 @@ class is_forward_iterator { ...@@ -210,7 +185,7 @@ class is_forward_iterator {
static bool sfinae_fun( static bool sfinae_fun(
C* iter, C* iter,
// check for 'C::value_type C::operator*()' returning a non-void type // check for 'C::value_type C::operator*()' returning a non-void type
typename rm_const_and_ref<decltype(*(*iter))>::type* = 0, typename std::decay<decltype(*(*iter))>::type* = 0,
// check for 'C& C::operator++()' // check for 'C& C::operator++()'
typename std::enable_if< typename std::enable_if<
std::is_same<C&, decltype(++(*iter))>::value>::type* = 0, std::is_same<C&, decltype(++(*iter))>::value>::type* = 0,
...@@ -242,12 +217,12 @@ class is_iterable { ...@@ -242,12 +217,12 @@ class is_iterable {
static bool sfinae_fun( static bool sfinae_fun(
const C* cc, const C* cc,
// check for 'C::begin()' returning a forward iterator // check for 'C::begin()' returning a forward iterator
typename std::enable_if< typename std::enable_if<is_forward_iterator<decltype(cc->begin())>::value>::
detail::is_forward_iterator<decltype(cc->begin())>::value>::type* = type* = 0,
0,
// check for 'C::end()' returning the same kind of forward iterator // check for 'C::end()' returning the same kind of forward iterator
typename std::enable_if<std::is_same< typename std::enable_if<std::is_same<decltype(cc->begin()),
decltype(cc->begin()), decltype(cc->end())>::value>::type* = 0) { decltype(cc->end())>::value>::type
* = 0) {
return true; return true;
} }
...@@ -257,7 +232,7 @@ class is_iterable { ...@@ -257,7 +232,7 @@ class is_iterable {
using result_type = decltype(sfinae_fun(static_cast<const T*>(nullptr))); using result_type = decltype(sfinae_fun(static_cast<const T*>(nullptr)));
public: public:
static constexpr bool value = detail::is_primitive<T>::value == false && static constexpr bool value = is_primitive<T>::value == false &&
std::is_same<bool, result_type>::value; std::is_same<bool, result_type>::value;
}; };
...@@ -358,7 +333,7 @@ struct get_callable_trait_helper<false, false, C> { ...@@ -358,7 +333,7 @@ struct get_callable_trait_helper<false, false, C> {
template <class T> template <class T>
struct get_callable_trait { struct get_callable_trait {
// type without cv qualifiers // type without cv qualifiers
using bare_type = typename rm_const_and_ref<T>::type; using bare_type = typename std::decay<T>::type;
// if T is a function pointer, this type identifies the function // if T is a function pointer, this type identifies the function
using signature_type = typename std::remove_pointer<bare_type>::type; using signature_type = typename std::remove_pointer<bare_type>::type;
using type = using type =
...@@ -392,7 +367,7 @@ struct is_callable { ...@@ -392,7 +367,7 @@ struct is_callable {
static void _fun(void*) { } static void _fun(void*) { }
using pointer = typename rm_const_and_ref<T>::type*; using pointer = typename std::decay<T>::type*;
using result_type = decltype(_fun(static_cast<pointer>(nullptr))); using result_type = decltype(_fun(static_cast<pointer>(nullptr)));
......
...@@ -54,7 +54,7 @@ struct deduce_signature_helper<std::tuple<Rs...>, type_list<Ts...>> { ...@@ -54,7 +54,7 @@ struct deduce_signature_helper<std::tuple<Rs...>, type_list<Ts...>> {
template <class T> template <class T>
struct deduce_signature { struct deduce_signature {
using result_ = typename implicit_conversions<typename T::result_type>::type; using result_ = typename implicit_conversions<typename T::result_type>::type;
using arg_t = typename tl_map<typename T::arg_types, rm_const_and_ref>::type; using arg_t = typename tl_map<typename T::arg_types, std::decay>::type;
using type = typename deduce_signature_helper<result_, arg_t>::type; using type = typename deduce_signature_helper<result_, arg_t>::type;
}; };
...@@ -72,7 +72,7 @@ inline void assert_types() { ...@@ -72,7 +72,7 @@ inline void assert_types() {
using arg_types = using arg_types =
typename tl_map< typename tl_map<
typename get_callable_trait<F>::arg_types, typename get_callable_trait<F>::arg_types,
rm_const_and_ref std::decay
>::type; >::type;
static constexpr size_t fun_args = tl_size<arg_types>::value; static constexpr size_t fun_args = tl_size<arg_types>::value;
static_assert(fun_args <= tl_size<OutputList>::value, static_assert(fun_args <= tl_size<OutputList>::value,
......
...@@ -179,7 +179,7 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> { ...@@ -179,7 +179,7 @@ class local_actor : public extend<abstract_actor>::with<mixin::memory_cached> {
void send(const typed_actor<Rs...>& whom, Ts... what) { void send(const typed_actor<Rs...>& whom, Ts... what) {
check_typed_input(whom, check_typed_input(whom,
detail::type_list<typename detail::implicit_conversions< detail::type_list<typename detail::implicit_conversions<
typename detail::rm_const_and_ref<Ts>::type typename std::decay<Ts>::type
>::type...>{}); >::type...>{});
send_tuple(message_priority::normal, actor{whom.m_ptr.get()}, send_tuple(message_priority::normal, actor{whom.m_ptr.get()},
make_message(std::forward<Ts>(what)...)); make_message(std::forward<Ts>(what)...));
......
...@@ -410,7 +410,7 @@ struct get_case<false, Expr, Trans, Pattern> { ...@@ -410,7 +410,7 @@ struct get_case<false, Expr, Trans, Pattern> {
using rhs_pattern = using rhs_pattern =
typename detail::tl_map< typename detail::tl_map<
typename detail::get_callable_trait<Expr>::arg_types, typename detail::get_callable_trait<Expr>::arg_types,
detail::rm_const_and_ref std::decay
>::type; >::type;
using type = using type =
typename get_case_< typename get_case_<
...@@ -468,7 +468,7 @@ Result unroll_expr(PPFPs& fs, uint64_t bitmask, long_constant<N>, ...@@ -468,7 +468,7 @@ Result unroll_expr(PPFPs& fs, uint64_t bitmask, long_constant<N>,
} }
if ((bitmask & (0x01 << N)) == 0) return none; if ((bitmask & (0x01 << N)) == 0) return none;
auto& f = get<N>(fs); auto& f = get<N>(fs);
using Fun = typename detail::rm_const_and_ref<decltype(f)>::type; using Fun = typename std::decay<decltype(f)>::type;
using pattern_type = typename Fun::pattern_type; using pattern_type = typename Fun::pattern_type;
//using policy = detail::invoke_util<pattern_type>; //using policy = detail::invoke_util<pattern_type>;
typedef detail::invoke_util<pattern_type> policy; // using fails on GCC 4.7 typedef detail::invoke_util<pattern_type> policy; // using fails on GCC 4.7
...@@ -493,7 +493,7 @@ template <class Case, long N, class Tuple> ...@@ -493,7 +493,7 @@ template <class Case, long N, class Tuple>
inline uint64_t calc_bitmask(Case& fs, long_constant<N>, inline uint64_t calc_bitmask(Case& fs, long_constant<N>,
const std::type_info& tinf, const Tuple& tup) { const std::type_info& tinf, const Tuple& tup) {
auto& f = get<N>(fs); auto& f = get<N>(fs);
using Fun = typename detail::rm_const_and_ref<decltype(f)>::type; using Fun = typename std::decay<decltype(f)>::type;
using pattern_type = typename Fun::pattern_type; using pattern_type = typename Fun::pattern_type;
using policy = detail::invoke_util<pattern_type>; using policy = detail::invoke_util<pattern_type>;
uint64_t result = policy::can_invoke(tinf, tup) ? (0x01 << N) : 0x00; uint64_t result = policy::can_invoke(tinf, tup) ? (0x01 << N) : 0x00;
...@@ -525,7 +525,7 @@ struct mexpr_fwd { ...@@ -525,7 +525,7 @@ struct mexpr_fwd {
IsManipulator, IsManipulator,
T, T,
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename detail::rm_const_and_ref<T>::type typename std::decay<T>::type
>::type >::type
>::type; >::type;
}; };
......
...@@ -295,7 +295,7 @@ inline bool operator!=(const message& lhs, const message& rhs) { ...@@ -295,7 +295,7 @@ inline bool operator!=(const message& lhs, const message& rhs) {
*/ */
template <class T, class... Ts> template <class T, class... Ts>
typename std::enable_if< typename std::enable_if<
!std::is_same<message, typename detail::rm_const_and_ref<T>::type>::value !std::is_same<message, typename std::decay<T>::type>::value
|| (sizeof...(Ts) > 0), || (sizeof...(Ts) > 0),
message message
>::type >::type
......
...@@ -60,7 +60,7 @@ class message_builder { ...@@ -60,7 +60,7 @@ class message_builder {
*/ */
template <class Iter> template <class Iter>
message_builder& append(Iter first, Iter last) { message_builder& append(Iter first, Iter last) {
using vtype = typename detail::rm_const_and_ref<decltype(*first)>::type; using vtype = typename std::decay<decltype(*first)>::type;
using converted = typename detail::implicit_conversions<vtype>::type; using converted = typename detail::implicit_conversions<vtype>::type;
auto uti = uniform_typeid<converted>(); auto uti = uniform_typeid<converted>();
for (; first != last; ++first) { for (; first != last; ++first) {
......
...@@ -96,7 +96,7 @@ class message_handler { ...@@ -96,7 +96,7 @@ class message_handler {
template <class... Ts> template <class... Ts>
typename std::conditional< typename std::conditional<
detail::disjunction<may_have_timeout< detail::disjunction<may_have_timeout<
typename detail::rm_const_and_ref<Ts>::type>::value...>::value, typename std::decay<Ts>::type>::value...>::value,
behavior, behavior,
message_handler message_handler
>::type >::type
......
...@@ -66,7 +66,7 @@ class behavior_stack_based_impl : public single_timeout<Base, Subtype> { ...@@ -66,7 +66,7 @@ class behavior_stack_based_impl : public single_timeout<Base, Subtype> {
template <class T, class... Ts> template <class T, class... Ts>
inline typename std::enable_if< inline typename std::enable_if<
!is_behavior_policy<typename detail::rm_const_and_ref<T>::type>::value, !is_behavior_policy<typename std::decay<T>::type>::value,
void>::type void>::type
become(T&& arg, Ts&&... args) { become(T&& arg, Ts&&... args) {
do_become( do_become(
......
...@@ -157,14 +157,14 @@ class sync_sender_impl : public Base { ...@@ -157,14 +157,14 @@ class sync_sender_impl : public Base {
typename detail::deduce_output_type< typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Rs...>,
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename detail::rm_const_and_ref<Ts>::type>::type...>::type, typename std::decay<Ts>::type>::type...>::type,
ResponseHandleTag> ResponseHandleTag>
sync_send(message_priority prio, const typed_actor<Rs...>& dest, sync_send(message_priority prio, const typed_actor<Rs...>& dest,
Ts&&... what) { Ts&&... what) {
return sync_send_impl( return sync_send_impl(
prio, dest, prio, dest,
detail::type_list<typename detail::implicit_conversions< detail::type_list<typename detail::implicit_conversions<
typename detail::rm_const_and_ref<Ts>::type>::type...>{}, typename std::decay<Ts>::type>::type...>{},
make_message(std::forward<Ts>(what)...)); make_message(std::forward<Ts>(what)...));
} }
...@@ -174,13 +174,13 @@ class sync_sender_impl : public Base { ...@@ -174,13 +174,13 @@ class sync_sender_impl : public Base {
typename detail::deduce_output_type< typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Rs...>,
detail::type_list<typename detail::implicit_conversions< detail::type_list<typename detail::implicit_conversions<
typename detail::rm_const_and_ref<Ts>::type>::type...>>::type, typename std::decay<Ts>::type>::type...>>::type,
ResponseHandleTag> ResponseHandleTag>
sync_send(const typed_actor<Rs...>& dest, Ts&&... what) { sync_send(const typed_actor<Rs...>& dest, Ts&&... what) {
return sync_send_impl( return sync_send_impl(
message_priority::normal, dest, message_priority::normal, dest,
detail::type_list<typename detail::implicit_conversions< detail::type_list<typename detail::implicit_conversions<
typename detail::rm_const_and_ref<Ts>::type>::type...>{}, typename std::decay<Ts>::type>::type...>{},
make_message(std::forward<Ts>(what)...)); make_message(std::forward<Ts>(what)...));
} }
...@@ -232,7 +232,7 @@ class sync_sender_impl : public Base { ...@@ -232,7 +232,7 @@ class sync_sender_impl : public Base {
typename detail::deduce_output_type< typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Rs...>,
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename detail::rm_const_and_ref<Ts>::type>::type...>::type, typename std::decay<Ts>::type>::type...>::type,
ResponseHandleTag> ResponseHandleTag>
timed_sync_send(message_priority prio, const typed_actor<Rs...>& dest, timed_sync_send(message_priority prio, const typed_actor<Rs...>& dest,
const duration& rtime, Ts&&... what) { const duration& rtime, Ts&&... what) {
...@@ -247,7 +247,7 @@ class sync_sender_impl : public Base { ...@@ -247,7 +247,7 @@ class sync_sender_impl : public Base {
typename detail::deduce_output_type< typename detail::deduce_output_type<
detail::type_list<Rs...>, detail::type_list<Rs...>,
typename detail::implicit_conversions< typename detail::implicit_conversions<
typename detail::rm_const_and_ref<Ts>::type>::type...>::type, typename std::decay<Ts>::type>::type...>::type,
ResponseHandleTag> ResponseHandleTag>
timed_sync_send(const typed_actor<Rs...>& dest, const duration& rtime, timed_sync_send(const typed_actor<Rs...>& dest, const duration& rtime,
Ts&&... what) { Ts&&... what) {
......
...@@ -200,7 +200,7 @@ struct pattern_type_ { ...@@ -200,7 +200,7 @@ struct pattern_type_ {
static_assert(detail::tl_size<args>::value == 1, static_assert(detail::tl_size<args>::value == 1,
"only unary functions allowed"); "only unary functions allowed");
using type = using type =
typename detail::rm_const_and_ref< typename std::decay<
typename detail::tl_head<args>::type typename detail::tl_head<args>::type
>::type; >::type;
}; };
...@@ -209,7 +209,7 @@ template <class T> ...@@ -209,7 +209,7 @@ template <class T>
struct pattern_type_<false, T> { struct pattern_type_<false, T> {
using type = using type =
typename implicit_conversions< typename implicit_conversions<
typename detail::rm_const_and_ref< typename std::decay<
typename detail::unboxed<T>::type typename detail::unboxed<T>::type
>::type >::type
>::type; >::type;
......
...@@ -192,7 +192,7 @@ class response_handle<Self, detail::type_list<Ts...>, ...@@ -192,7 +192,7 @@ class response_handle<Self, detail::type_list<Ts...>,
using arg_types = using arg_types =
typename detail::tl_map< typename detail::tl_map<
typename detail::get_callable_trait<F>::arg_types, typename detail::get_callable_trait<F>::arg_types,
detail::rm_const_and_ref std::decay
>::type; >::type;
static constexpr size_t fun_args = detail::tl_size<arg_types>::value; static constexpr size_t fun_args = detail::tl_size<arg_types>::value;
static_assert(fun_args <= detail::tl_size<result_types>::value, static_assert(fun_args <= detail::tl_size<result_types>::value,
......
...@@ -71,7 +71,7 @@ template <class... Rs, class... Ts> ...@@ -71,7 +71,7 @@ template <class... Rs, class... Ts>
void anon_send(const typed_actor<Rs...>& whom, Ts&&... args) { void anon_send(const typed_actor<Rs...>& whom, Ts&&... args) {
check_typed_input(whom, check_typed_input(whom,
detail::type_list<typename detail::implicit_conversions< detail::type_list<typename detail::implicit_conversions<
typename detail::rm_const_and_ref<Ts>::type typename std::decay<Ts>::type
>::type...>{}); >::type...>{});
anon_send(actor_cast<channel>(whom), std::forward<Ts>(args)...); anon_send(actor_cast<channel>(whom), std::forward<Ts>(args)...);
} }
......
...@@ -124,7 +124,7 @@ intrusive_ptr<C> spawn_impl(execution_unit* host, ...@@ -124,7 +124,7 @@ intrusive_ptr<C> spawn_impl(execution_unit* host,
*/ */
template <class T> template <class T>
typename std::conditional< typename std::conditional<
is_convertible_to_actor<typename detail::rm_const_and_ref<T>::type>::value, is_convertible_to_actor<typename std::decay<T>::type>::value,
actor, actor,
T&& T&&
>::type >::type
...@@ -138,7 +138,7 @@ spawn_fwd(typename std::remove_reference<T>::type& arg) noexcept { ...@@ -138,7 +138,7 @@ spawn_fwd(typename std::remove_reference<T>::type& arg) noexcept {
*/ */
template <class T> template <class T>
typename std::conditional< typename std::conditional<
is_convertible_to_actor<typename detail::rm_const_and_ref<T>::type>::value, is_convertible_to_actor<typename std::decay<T>::type>::value,
actor, actor,
T&& T&&
>::type >::type
......
...@@ -202,7 +202,7 @@ class variant { ...@@ -202,7 +202,7 @@ class variant {
template <class U> template <class U>
void set(U&& arg) { void set(U&& arg) {
using type = typename detail::rm_const_and_ref<U>::type; using type = typename std::decay<U>::type;
static constexpr int type_id = detail::tl_find_if< static constexpr int type_id = detail::tl_find_if<
types, types,
detail::tbind< detail::tbind<
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment