Commit 1a48d179 authored by Dominik Charousset's avatar Dominik Charousset

maintenance

bundled all type trait classes in header "cppa/util/type_traits.hpp" and
refactored some code pieces for clearity
parent 1283bd5c
......@@ -145,31 +145,14 @@ cppa/tuple_cast.hpp
cppa/uniform_type_info.hpp
cppa/util/abstract_uniform_type_info.hpp
cppa/util/arg_match_t.hpp
cppa/util/at.hpp
cppa/util/buffer.hpp
cppa/util/call.hpp
cppa/util/callable_trait.hpp
cppa/util/comparable.hpp
cppa/util/compare_tuples.hpp
cppa/util/conjunction.hpp
cppa/util/deduce_ref_type.hpp
cppa/util/disjunction.hpp
cppa/util/dptr.hpp
cppa/util/duration.hpp
cppa/util/element_at.hpp
cppa/util/fiber.hpp
cppa/util/get_result_type.hpp
cppa/util/int_list.hpp
cppa/util/is_array_of.hpp
cppa/util/is_builtin.hpp
cppa/util/is_callable.hpp
cppa/util/is_comparable.hpp
cppa/util/is_forward_iterator.hpp
cppa/util/is_iterable.hpp
cppa/util/is_legal_tuple_type.hpp
cppa/util/is_manipulator.hpp
cppa/util/is_mutable_ref.hpp
cppa/util/is_primitive.hpp
cppa/util/left_or_right.hpp
cppa/util/limited_vector.hpp
cppa/util/producer_consumer_list.hpp
......@@ -177,10 +160,7 @@ cppa/util/pt_dispatch.hpp
cppa/util/pt_token.hpp
cppa/util/purge_refs.hpp
cppa/util/rebindable_reference.hpp
cppa/util/replace_type.hpp
cppa/util/ripemd_160.hpp
cppa/util/rm_option.hpp
cppa/util/rm_ref.hpp
cppa/util/scope_guard.hpp
cppa/util/shared_lock_guard.hpp
cppa/util/shared_spinlock.hpp
......@@ -313,3 +293,4 @@ cppa/util/get_mac_addresses.hpp
src/get_mac_addresses.cpp
cppa/util/get_root_uuid.hpp
src/get_root_uuid.cpp
cppa/util/type_traits.hpp
......@@ -46,7 +46,7 @@
#include "cppa/exit_reason.hpp"
#include "cppa/intrusive_ptr.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa {
......@@ -247,7 +247,7 @@ struct functor_attachable : attachable {
template<typename F>
bool actor::attach_functor(F&& f) {
typedef typename util::rm_ref<F>::type f_type;
typedef typename util::rm_const_and_ref<F>::type f_type;
typedef functor_attachable<f_type> impl;
return attach(attachable_ptr{new impl(std::forward<F>(f))});
}
......
......@@ -59,7 +59,7 @@ class actor_companion_mixin : public Base {
public:
typedef std::unique_ptr<mailbox_element,detail::disposer> message_pointer;
typedef std::unique_ptr<mailbox_element, detail::disposer> message_pointer;
template<typename... Ts>
actor_companion_mixin(Ts&&... args) : super(std::forward<Ts>(args)...) {
......@@ -128,8 +128,12 @@ class actor_companion_mixin : public Base {
}
void enqueue(const message_header& hdr, any_tuple msg) override {
using std::move;
util::shared_lock_guard<lock_type> guard(m_lock);
if (m_parent) push_message(hdr, std::move(msg));
if (!m_parent) return;
message_pointer ptr;
ptr.reset(detail::memory::create<mailbox_element>(hdr, move(msg)));
m_parent->new_message(move(ptr));
}
bool initialized() const override { return true; }
......@@ -158,13 +162,6 @@ class actor_companion_mixin : public Base {
private:
template<typename... Ts>
void push_message(Ts&&... args) {
message_pointer ptr;
ptr.reset(detail::memory::create<mailbox_element>(std::forward<Ts>(args)...));
m_parent->new_message(std::move(ptr));
}
void throw_no_become() {
throw std::runtime_error("actor_companion_companion "
"does not support libcppa's "
......
......@@ -50,8 +50,8 @@ namespace cppa {
* The output of this example program is:
*
* <tt>
* foo(1,2)<br>
* foo_pair(3,4)
* foo(1, 2)<br>
* foo_pair(3, 4)
* </tt>
* @example announce_1.cpp
*/
......@@ -61,7 +61,7 @@ namespace cppa {
*
* The output of this example program is:
*
* <tt>foo(1,2)</tt>
* <tt>foo(1, 2)</tt>
* @example announce_2.cpp
*/
......@@ -71,7 +71,7 @@ namespace cppa {
*
* The output of this example program is:
*
* <tt>foo(1,2)</tt>
* <tt>foo(1, 2)</tt>
* @example announce_3.cpp
*/
......@@ -80,7 +80,7 @@ namespace cppa {
*
* The output of this example program is:
*
* <tt>bar(foo(1,2),3)</tt>
* <tt>bar(foo(1, 2), 3)</tt>
* @example announce_4.cpp
*/
......@@ -142,11 +142,11 @@ compound_member(C& (Parent::*getter)(), const Ts&... args) {
template<class Parent, typename GRes,
typename SRes, typename SArg, typename... Ts>
std::pair<std::pair<GRes (Parent::*)() const, SRes (Parent::*)(SArg)>,
util::abstract_uniform_type_info<typename util::rm_ref<GRes>::type>*>
util::abstract_uniform_type_info<typename util::rm_const_and_ref<GRes>::type>*>
compound_member(const std::pair<GRes (Parent::*)() const,
SRes (Parent::*)(SArg) >& gspair,
const Ts&... args) {
typedef typename util::rm_ref<GRes>::type mtype;
typedef typename util::rm_const_and_ref<GRes>::type mtype;
return {gspair, new detail::default_uniform_type_info_impl<mtype>(args...)};
}
......@@ -159,7 +159,8 @@ compound_member(const std::pair<GRes (Parent::*)() const,
*/
template<typename T, typename... Ts>
inline bool announce(const Ts&... args) {
return announce(typeid(T), new detail::default_uniform_type_info_impl<T>(args...));
auto ptr = new detail::default_uniform_type_info_impl<T>(args...);
return announce(typeid(T), ptr);
}
/**
......
......@@ -37,9 +37,8 @@
#include "cppa/cow_ptr.hpp"
#include "cppa/cow_tuple.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/comparable.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/detail/tuple_view.hpp"
#include "cppa/detail/abstract_tuple.hpp"
......@@ -57,7 +56,12 @@ class any_tuple {
public:
/**
* @brief A smart pointer to the internal implementation.
* @brief A raw pointer to the data.
*/
typedef detail::abstract_tuple* raw_ptr;
/**
* @brief A smart pointer to the data.
*/
typedef cow_ptr<detail::abstract_tuple> data_ptr;
......@@ -195,7 +199,7 @@ class any_tuple {
void reset();
explicit any_tuple(detail::abstract_tuple*);
explicit any_tuple(raw_ptr);
/** @endcond */
......@@ -212,22 +216,22 @@ class any_tuple {
static any_tuple view(T&& value, std::false_type, CanOptimize token);
template<typename T, typename U>
static any_tuple view(std::pair<T,U> p, std::false_type);
static any_tuple view(std::pair<T, U> p, std::false_type);
template<typename T>
static detail::abstract_tuple* simple_view(T& value, std::true_type);
static auto simple_view(T& value, std::true_type) -> raw_ptr;
template<typename T, typename U>
static detail::abstract_tuple* simple_view(std::pair<T,U>& p, std::true_type);
static auto simple_view(std::pair<T, U>& p, std::true_type) -> raw_ptr;
template<typename T>
static detail::abstract_tuple* simple_view(T&& value, std::false_type);
static auto simple_view(T&& value, std::false_type) -> raw_ptr;
template<typename T>
static detail::abstract_tuple* container_view(T& value, std::true_type);
static auto container_view(T& value, std::true_type) -> raw_ptr;
template<typename T>
static detail::abstract_tuple* container_view(T&& value, std::false_type);
static auto container_view(T&& value, std::false_type) -> raw_ptr;
};
......@@ -310,27 +314,27 @@ template<typename T, bool IsIterable = true>
struct any_tuple_view_trait_impl {
static constexpr bool is_mutable_ref = std::is_reference<T>::value
&& !std::is_const<T>::value;
typedef std::integral_constant<bool,is_mutable_ref> can_optimize;
typedef std::integral_constant<bool,true> is_container;
typedef std::integral_constant<bool, is_mutable_ref> can_optimize;
typedef std::integral_constant<bool, true> is_container;
};
template<typename T>
struct any_tuple_view_trait_impl<T,false> {
typedef typename util::rm_ref<T>::type type;
struct any_tuple_view_trait_impl<T, false> {
typedef typename util::rm_const_and_ref<T>::type type;
typedef typename detail::implicit_conversions<type>::type mapped;
static_assert(util::is_legal_tuple_type<mapped>::value,
"T is not a valid tuple type");
static constexpr bool is_mutable_ref = std::is_same<mapped,type>::value
static constexpr bool is_mutable_ref = std::is_same<mapped, type>::value
&& std::is_reference<T>::value
&& not std::is_const<T>::value;
typedef std::integral_constant<bool,is_mutable_ref> can_optimize;
typedef std::integral_constant<bool,false> is_container;
typedef std::integral_constant<bool, is_mutable_ref> can_optimize;
typedef std::integral_constant<bool, false> is_container;
};
template<typename T>
struct any_tuple_view_trait {
typedef typename util::rm_ref<T>::type type;
typedef any_tuple_view_trait_impl<T,util::is_iterable<type>::value> impl;
typedef typename util::rm_const_and_ref<T>::type type;
typedef any_tuple_view_trait_impl<T, util::is_iterable<type>::value> impl;
typedef typename impl::can_optimize can_optimize;
typedef typename impl::is_container is_container;
};
......@@ -354,35 +358,35 @@ any_tuple any_tuple::view(T&& v, std::false_type, CanOptimize t) {
}
template<typename T>
detail::abstract_tuple* any_tuple::simple_view(T& v, std::true_type) {
auto any_tuple::simple_view(T& v, std::true_type) -> raw_ptr {
return new detail::tuple_view<T>(&v);
}
template<typename T, typename U>
detail::abstract_tuple* any_tuple::simple_view(std::pair<T,U>& p, std::true_type) {
return new detail::tuple_view<T,U>(&p.first, &p.second);
auto any_tuple::simple_view(std::pair<T, U>& p, std::true_type) -> raw_ptr {
return new detail::tuple_view<T, U>(&p.first, &p.second);
}
template<typename T>
detail::abstract_tuple* any_tuple::simple_view(T&& v, std::false_type) {
typedef typename util::rm_ref<T>::type vtype;
auto any_tuple::simple_view(T&& v, std::false_type) -> raw_ptr {
typedef typename util::rm_const_and_ref<T>::type vtype;
typedef typename detail::implicit_conversions<vtype>::type converted;
return new detail::tuple_vals<converted>(std::forward<T>(v));
}
template<typename T, typename U>
any_tuple any_tuple::view(std::pair<T,U> p, std::false_type) {
return new detail::tuple_vals<T,U>(std::move(p.first), std::move(p.second));
any_tuple any_tuple::view(std::pair<T, U> p, std::false_type) {
return new detail::tuple_vals<T, U>(std::move(p.first), std::move(p.second));
}
template<typename T>
detail::abstract_tuple* any_tuple::container_view(T& v, std::true_type) {
auto any_tuple::container_view(T& v, std::true_type) -> raw_ptr {
return new detail::container_tuple_view<T>(&v);
}
template<typename T>
detail::abstract_tuple* any_tuple::container_view(T&& v, std::false_type) {
auto vptr = new typename util::rm_ref<T>::type(std::forward<T>(v));
auto any_tuple::container_view(T&& v, std::false_type) -> raw_ptr {
auto vptr = new typename util::rm_const_and_ref<T>::type(std::forward<T>(v));
return new detail::container_tuple_view<T>(vptr, true);
}
......
......@@ -37,10 +37,9 @@
#include "cppa/match_expr.hpp"
#include "cppa/timeout_definition.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/duration.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa {
......@@ -81,11 +80,11 @@ class behavior {
template<typename F>
behavior(util::duration d, F f);
template<typename... Cases>
behavior(const match_expr<Cases...>& arg);
template<typename... Cs>
behavior(const match_expr<Cs...>& arg);
template<typename... Cases, typename T, typename... Ts>
behavior(const match_expr<Cases...>& arg0, const T& arg1, const Ts&... args);
template<typename... Cs, typename T, typename... Ts>
behavior(const match_expr<Cs...>& arg0, const T& arg1, const Ts&... args);
/**
* @brief Invokes the timeout callback.
......@@ -122,8 +121,8 @@ class behavior {
* @brief Creates a behavior from a match expression and a timeout definition.
* @relates behavior
*/
template<typename... Cases, typename F>
inline behavior operator,(const match_expr<Cases...>& lhs,
template<typename... Cs, typename F>
inline behavior operator,(const match_expr<Cs...>& lhs,
const timeout_definition<F>& rhs) {
return match_expr_convert(lhs, rhs);
}
......@@ -135,21 +134,19 @@ inline behavior operator,(const match_expr<Cases...>& lhs,
template<typename F>
behavior::behavior(const timeout_definition<F>& arg)
: m_impl(detail::new_default_behavior_impl(detail::dummy_match_expr{},
arg.timeout,
arg.handler) ) { }
: m_impl(detail::new_default_behavior(arg.timeout, arg.handler)) { }
template<typename F>
behavior::behavior(util::duration d, F f)
: m_impl(detail::new_default_behavior_impl(detail::dummy_match_expr{}, d, f)) { }
: m_impl(detail::new_default_behavior(d, f)) { }
template<typename... Cases>
behavior::behavior(const match_expr<Cases...>& arg)
template<typename... Cs>
behavior::behavior(const match_expr<Cs...>& arg)
: m_impl(arg.as_behavior_impl()) { }
template<typename... Cases, typename T, typename... Ts>
behavior::behavior(const match_expr<Cases...>& arg0, const T& arg1, const Ts&... args)
: m_impl(detail::match_expr_concat(arg0, arg1, args...)) { }
template<typename... Cs, typename T, typename... Ts>
behavior::behavior(const match_expr<Cs...>& v0, const T& v1, const Ts&... vs)
: m_impl(detail::match_expr_concat(v0, v1, vs...)) { }
inline behavior::behavior(impl_ptr ptr) : m_impl(std::move(ptr)) { }
......
......@@ -89,7 +89,7 @@ typedef intrusive_ptr<channel> channel_ptr;
* @brief Convenience alias.
*/
template<typename T, typename R = void>
using enable_if_channel = std::enable_if<std::is_base_of<channel,T>::value,R>;
using enable_if_channel = std::enable_if<std::is_base_of<channel, T>::value, R>;
} // namespace cppa
......
......@@ -48,7 +48,7 @@ namespace cppa {
* @brief Context-switching actor implementation.
* @extends scheduled_actor
*/
class context_switching_actor : public extend<scheduled_actor,context_switching_actor>::with<stacked> {
class context_switching_actor : public extend<scheduled_actor, context_switching_actor>::with<stacked> {
friend class detail::behavior_stack;
friend class detail::receive_policy;
......
......@@ -41,11 +41,9 @@
#include "cppa/cow_ptr.hpp"
#include "cppa/ref_counted.hpp"
#include "cppa/util/at.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/limited_vector.hpp"
#include "cppa/util/is_comparable.hpp"
#include "cppa/util/compare_tuples.hpp"
#include "cppa/util/is_legal_tuple_type.hpp"
#include "cppa/detail/tuple_vals.hpp"
#include "cppa/detail/decorated_tuple.hpp"
......@@ -184,8 +182,8 @@ struct cow_tuple_from_type_list< util::type_list<Ts...> > {
* @relates cow_tuple
*/
template<size_t N, typename... Ts>
const typename util::at<N, Ts...>::type& get(const cow_tuple<Ts...>& tup) {
typedef typename util::at<N, Ts...>::type result_type;
const typename util::type_at<N, Ts...>::type& get(const cow_tuple<Ts...>& tup) {
typedef typename util::type_at<N, Ts...>::type result_type;
return *reinterpret_cast<const result_type*>(tup.at(N));
}
......@@ -195,12 +193,12 @@ const typename util::at<N, Ts...>::type& get(const cow_tuple<Ts...>& tup) {
* @param tup The cow_tuple object.
* @returns A reference of type T, whereas T is the type of the
* <tt>N</tt>th element of @p tup.
* @note Detaches @p tup if there are two or more references to the cow_tuple data.
* @note Detaches @p tup if there are two or more references to the cow_tuple.
* @relates cow_tuple
*/
template<size_t N, typename... Ts>
typename util::at<N, Ts...>::type& get_ref(cow_tuple<Ts...>& tup) {
typedef typename util::at<N, Ts...>::type result_type;
typename util::type_at<N, Ts...>::type& get_ref(cow_tuple<Ts...>& tup) {
typedef typename util::type_at<N, Ts...>::type result_type;
return *reinterpret_cast<result_type*>(tup.mutable_at(N));
}
......
......@@ -66,7 +66,7 @@
#include "cppa/scheduled_actor.hpp"
#include "cppa/event_based_actor.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/network/acceptor.hpp"
#include "cppa/detail/memory.hpp"
......@@ -165,7 +165,7 @@
* passing implementation.
*
* {@link cppa::cow_tuple Tuples} should @b always be used with by-value
* semantic,since tuples use a copy-on-write smart pointer internally.
* semantic, since tuples use a copy-on-write smart pointer internally.
* Let's assume two
* tuple @p x and @p y, whereas @p y is a copy of @p x:
*
......@@ -358,7 +358,7 @@
* delayed_send(self, std::chrono::seconds(1), atom("poll"));
* receive_loop (
* // ...
* on(atom("poll")) >> []() {
* on(atom("poll")) >> [] {
* // ... poll something ...
* // and do it again after 1sec
* delayed_send(self, std::chrono::seconds(1), atom("poll"));
......@@ -394,12 +394,13 @@
*
* receive (
* // equal to: on(std::string("hello actor!"))
* on("hello actor!") >> []() { }
* on("hello actor!") >> [] { }
* );
* @endcode
*
* @defgroup ActorCreation Actor creation.
*
* @defgroup MetaProgramming Metaprogramming utility.
*/
// examples
......@@ -444,7 +445,7 @@ namespace cppa {
* @returns @p whom.
*/
template<class C>
inline typename enable_if_channel<C,const intrusive_ptr<C>&>::type
inline typename enable_if_channel<C, const intrusive_ptr<C>&>::type
operator<<(const intrusive_ptr<C>& whom, any_tuple what) {
send_tuple(whom, std::move(what));
return whom;
......@@ -496,11 +497,11 @@ actor_ptr spawn(Ts&&... args) {
*/
template<class Impl, spawn_options Options = no_spawn_options, typename... Ts>
actor_ptr spawn(Ts&&... args) {
static_assert(std::is_base_of<event_based_actor,Impl>::value,
static_assert(std::is_base_of<event_based_actor, Impl>::value,
"Impl is not a derived type of event_based_actor");
scheduled_actor_ptr ptr;
if (has_priority_aware_flag(Options)) {
using derived = typename extend<Impl>::template with<threaded,prioritizing>;
using derived = typename extend<Impl>::template with<threaded, prioritizing>;
ptr = make_counted<derived>(std::forward<Ts>(args)...);
}
else if (has_detach_flag(Options)) {
......@@ -590,7 +591,7 @@ void publish(actor_ptr whom, std::unique_ptr<network::acceptor> acceptor);
actor_ptr remote_actor(const char* host, std::uint16_t port);
/**
* @copydoc remote_actor(const char*,std::uint16_t)
* @copydoc remote_actor(const char*, std::uint16_t)
*/
inline actor_ptr remote_actor(const std::string& host, std::uint16_t port) {
return remote_actor(host.c_str(), port);
......@@ -677,8 +678,8 @@ inline const actor_ostream& operator<<(const actor_ostream& o, const any_tuple&
template<typename T>
inline typename std::enable_if<
!std::is_convertible<T,std::string>::value
&& !std::is_convertible<T,any_tuple>::value,
!std::is_convertible<T, std::string>::value
&& !std::is_convertible<T, any_tuple>::value,
const actor_ostream&
>::type
operator<<(const actor_ostream& o, T&& arg) {
......
......@@ -31,29 +31,39 @@
#ifndef CPPA_FWD_HPP
#define CPPA_FWD_HPP
#include <cstdint>
namespace cppa {
// classes
class actor;
class group;
class channel;
class behavior;
class any_tuple;
class self_type;
class message_header;
class partial_function;
class uniform_type_info;
class primitive_variant;
class process_information;
enum primitive_type : unsigned char;
// structs
struct anything;
template<typename>
class option;
// enums
enum primitive_type : unsigned char;
enum class atom_value : std::uint64_t;
template<typename>
class intrusive_ptr;
// class templates
template<typename> class option;
template<typename> class intrusive_ptr;
typedef intrusive_ptr<actor> actor_ptr;
typedef intrusive_ptr<group> group_ptr;
typedef intrusive_ptr<channel> channel_ptr;
// typedefs
typedef intrusive_ptr<actor> actor_ptr;
typedef intrusive_ptr<group> group_ptr;
typedef intrusive_ptr<channel> channel_ptr;
typedef intrusive_ptr<process_information> process_information_ptr;
} // namespace cppa
......
......@@ -130,7 +130,7 @@ class default_behavior_impl : public behavior_impl {
}
typename behavior_impl::pointer copy(const generic_timeout_definition& tdef) const {
return new default_behavior_impl<MatchExpr,std::function<void()> >(m_expr, tdef);
return new default_behavior_impl<MatchExpr, std::function<void()> >(m_expr, tdef);
}
void handle_timeout() { m_fun(); }
......@@ -143,10 +143,15 @@ class default_behavior_impl : public behavior_impl {
};
template<class MatchExpr, typename F>
default_behavior_impl<MatchExpr, F>* new_default_behavior_impl(const MatchExpr& mexpr, util::duration d, F f) {
default_behavior_impl<MatchExpr, F>* new_default_behavior(const MatchExpr& mexpr, util::duration d, F f) {
return new default_behavior_impl<MatchExpr, F>(mexpr, d, f);
}
template<typename F>
default_behavior_impl<dummy_match_expr, F>* new_default_behavior(util::duration d, F f) {
return new default_behavior_impl<dummy_match_expr, F>(dummy_match_expr{}, d, f);
}
template<typename F>
class continuation_decorator : public behavior_impl {
......
......@@ -54,7 +54,7 @@ class behavior_stack
behavior_stack(const behavior_stack&) = delete;
behavior_stack& operator=(const behavior_stack&) = delete;
typedef std::pair<behavior,message_id> element_type;
typedef std::pair<behavior, message_id> element_type;
public:
......
......@@ -37,12 +37,8 @@
#include "cppa/serializer.hpp"
#include "cppa/deserializer.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/void_type.hpp"
#include "cppa/util/is_builtin.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/is_forward_iterator.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/abstract_uniform_type_info.hpp"
#include "cppa/detail/types_array.hpp"
......@@ -87,7 +83,7 @@ template<typename T>
struct is_stl_pair : std::false_type { };
template<typename F, typename S>
struct is_stl_pair<std::pair<F,S> > : std::true_type { };
struct is_stl_pair<std::pair<F, S> > : std::true_type { };
template<typename T>
class builtin_member : public util::abstract_uniform_type_info<T> {
......@@ -110,11 +106,11 @@ class builtin_member : public util::abstract_uniform_type_info<T> {
};
typedef std::integral_constant<int,0> primitive_impl;
typedef std::integral_constant<int,1> list_impl;
typedef std::integral_constant<int,2> map_impl;
typedef std::integral_constant<int,3> pair_impl;
typedef std::integral_constant<int,9> recursive_impl;
typedef std::integral_constant<int, 0> primitive_impl;
typedef std::integral_constant<int, 1> list_impl;
typedef std::integral_constant<int, 2> map_impl;
typedef std::integral_constant<int, 3> pair_impl;
typedef std::integral_constant<int, 9> recursive_impl;
template<typename T>
constexpr int impl_id() {
......@@ -135,10 +131,10 @@ struct deconst_pair {
};
template<typename K, typename V>
struct deconst_pair<std::pair<K,V> > {
struct deconst_pair<std::pair<K, V> > {
typedef typename std::remove_const<K>::type first_type;
typedef typename std::remove_const<V>::type second_type;
typedef std::pair<first_type,second_type> type;
typedef std::pair<first_type, second_type> type;
};
class default_serialize_policy {
......@@ -147,13 +143,13 @@ class default_serialize_policy {
template<typename T>
void operator()(const T& val, serializer* s) const {
std::integral_constant<int,impl_id<T>()> token;
std::integral_constant<int, impl_id<T>()> token;
simpl(val, s, token);
}
template<typename T>
void operator()(T& val, deserializer* d) const {
std::integral_constant<int,impl_id<T>()> token;
std::integral_constant<int, impl_id<T>()> token;
dimpl(val, d, token);
//static_types_array<T>::arr[0]->deserialize(&val, d);
}
......@@ -380,31 +376,31 @@ struct fake_access_policy {
template<typename T, class C>
unique_uti new_member_tinfo(T C::* memptr) {
typedef memptr_access_policy<T,C> access_policy;
typedef member_tinfo<T,access_policy> result_type;
typedef memptr_access_policy<T, C> access_policy;
typedef member_tinfo<T, access_policy> result_type;
return unique_uti(new result_type(memptr));
}
template<typename T, class C>
unique_uti new_member_tinfo(T C::* memptr, std::unique_ptr<uniform_type_info> meminf) {
typedef memptr_access_policy<T,C> access_policy;
typedef member_tinfo<T,access_policy,forwarding_serialize_policy> result_type;
typedef memptr_access_policy<T, C> access_policy;
typedef member_tinfo<T, access_policy, forwarding_serialize_policy> result_type;
return unique_uti(new result_type(memptr, std::move(meminf)));
}
template<class C, typename GRes, typename SRes, typename SArg>
unique_uti new_member_tinfo(GRes (C::*getter)() const, SRes (C::*setter)(SArg)) {
typedef getter_setter_access_policy<C, GRes, SRes, SArg> access_policy;
typedef typename util::rm_ref<GRes>::type value_type;
typedef member_tinfo<value_type,access_policy> result_type;
typedef typename util::rm_const_and_ref<GRes>::type value_type;
typedef member_tinfo<value_type, access_policy> result_type;
return unique_uti(new result_type(access_policy(getter, setter)));
}
template<class C, typename GRes, typename SRes, typename SArg>
unique_uti new_member_tinfo(GRes (C::*getter)() const, SRes (C::*setter)(SArg), std::unique_ptr<uniform_type_info> meminf) {
typedef getter_setter_access_policy<C, GRes, SRes, SArg> access_policy;
typedef typename util::rm_ref<GRes>::type value_type;
typedef member_tinfo<value_type,access_policy,forwarding_serialize_policy> result_type;
typedef typename util::rm_const_and_ref<GRes>::type value_type;
typedef member_tinfo<value_type, access_policy, forwarding_serialize_policy> result_type;
return unique_uti(new result_type(access_policy(getter, setter), std::move(meminf)));
}
......@@ -443,7 +439,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
// pr.first = getter / setter pair
// pr.second = meta object to handle pr.first
template<typename GRes, typename SRes, typename SArg, typename C, typename... Ts>
void push_back(const std::pair<std::pair<GRes (C::*)() const, SRes (C::*)(SArg)>, util::abstract_uniform_type_info<typename util::rm_ref<GRes>::type>*>& pr,
void push_back(const std::pair<std::pair<GRes (C::*)() const, SRes (C::*)(SArg)>, util::abstract_uniform_type_info<typename util::rm_const_and_ref<GRes>::type>*>& pr,
Ts&&... args) {
m_members.push_back(new_member_tinfo(pr.first.first, pr.first.second, unique_uti(pr.second)));
push_back(std::forward<Ts>(args)...);
......@@ -457,7 +453,7 @@ class default_uniform_type_info_impl : public util::abstract_uniform_type_info<T
}
default_uniform_type_info_impl() {
typedef member_tinfo<T,fake_access_policy<T> > result_type;
typedef member_tinfo<T, fake_access_policy<T> > result_type;
m_members.push_back(unique_uti(new result_type));
}
......
......@@ -36,12 +36,12 @@
namespace cppa { namespace detail {
class empty_tuple : public singleton_mixin<empty_tuple,abstract_tuple> {
class empty_tuple : public singleton_mixin<empty_tuple, abstract_tuple> {
friend class singleton_manager;
friend class singleton_mixin<empty_tuple,abstract_tuple>;
friend class singleton_mixin<empty_tuple, abstract_tuple>;
typedef singleton_mixin<empty_tuple,abstract_tuple> super;
typedef singleton_mixin<empty_tuple, abstract_tuple> super;
public:
......
......@@ -55,7 +55,7 @@ class event_based_actor_impl : public event_based_actor {
void init() { apply(m_init); }
void on_exit() {
typedef typename util::get_arg_types<CleanupFun>::types arg_types;
typedef typename util::get_callable_trait<CleanupFun>::arg_types arg_types;
std::integral_constant<size_t, util::tl_size<arg_types>::value> token;
on_exit_impl(m_on_exit, token);
}
......@@ -126,8 +126,8 @@ struct ebaf_from_type_list<InitFun, CleanupFun, util::type_list<Ts...> > {
template<typename Init, typename Cleanup>
struct ebaf_from_functor {
typedef typename util::get_arg_types<Init>::types arg_types;
typedef typename util::get_arg_types<Cleanup>::types arg_types2;
typedef typename util::get_callable_trait<Init>::arg_types arg_types;
typedef typename util::get_callable_trait<Cleanup>::arg_types arg_types2;
static_assert(util::tl_forall<arg_types, std::is_pointer>::value,
"First functor takes non-pointer arguments");
static_assert( std::is_same<arg_types, arg_types2>::value
......
......@@ -34,8 +34,8 @@
#include <type_traits>
#include "cppa/util/call.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/int_list.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/detail/tdata.hpp"
#include "cppa/scheduled_actor.hpp"
......@@ -114,9 +114,8 @@ class ftor_behavior<false, true, F, Ts...> : public scheduled_actor {
ftor_behavior(const F& f, const Ts&... args) : m_fun(f), m_args(args...) {
}
ftor_behavior(F&& f,const Ts&... args) : m_fun(std::move(f))
, m_args(args...) {
}
ftor_behavior(F&& f, const Ts&... args)
: m_fun(std::move(f)), m_args(args...) { }
virtual void act() {
util::apply_args(m_fun, m_args, util::get_indices(m_args));
......@@ -125,7 +124,7 @@ class ftor_behavior<false, true, F, Ts...> : public scheduled_actor {
};
template<typename R>
scheduled_actor* get_behavior(std::integral_constant<bool,true>, R (*fptr)()) {
scheduled_actor* get_behavior(std::integral_constant<bool, true>, R (*fptr)()) {
static_assert(std::is_convertible<R, scheduled_actor*>::value == false,
"Spawning a function returning an actor_behavior? "
"Are you sure that you do not want to spawn the behavior "
......@@ -134,12 +133,12 @@ scheduled_actor* get_behavior(std::integral_constant<bool,true>, R (*fptr)()) {
}
template<typename F>
scheduled_actor* get_behavior(std::integral_constant<bool,false>, F&& ftor) {
scheduled_actor* get_behavior(std::integral_constant<bool, false>, F&& ftor) {
static_assert(std::is_convertible<decltype(ftor()), scheduled_actor*>::value == false,
"Spawning a functor returning an actor_behavior? "
"Are you sure that you do not want to spawn the behavior "
"returned by that functor?");
typedef typename util::rm_ref<F>::type ftype;
typedef typename util::rm_const_and_ref<F>::type ftype;
return new ftor_behavior<false, false, ftype>(std::forward<F>(ftor));
}
......@@ -159,7 +158,7 @@ scheduled_actor* get_behavior(std::false_type, F ftor, const T& arg, const Ts&..
"Spawning a functor returning an actor_behavior? "
"Are you sure that you do not want to spawn the behavior "
"returned by that functor?");
typedef typename util::rm_ref<F>::type ftype;
typedef typename util::rm_const_and_ref<F>::type ftype;
typedef ftor_behavior<false, true, ftype, T, Ts...> impl;
return new impl(std::forward<F>(ftor), arg, args...);
}
......
......@@ -37,9 +37,7 @@
#include "cppa/self.hpp"
#include "cppa/actor.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/is_array_of.hpp"
#include "cppa/util/replace_type.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa { class local_actor; }
......@@ -89,7 +87,7 @@ struct implicit_conversions {
template<typename T>
struct strip_and_convert {
typedef typename implicit_conversions<typename util::rm_ref<T>::type>::type
typedef typename implicit_conversions<typename util::rm_const_and_ref<T>::type>::type
type;
};
......
......@@ -229,8 +229,8 @@ struct matcher<wildcard_position::multiple, Tuple, T...> {
auto& tarr = static_types_array<T...>::arr;
if (tup.size() >= (sizeof...(T) - wc_count)) {
auto fpush = [](const typename Tuple::const_iterator&) { };
auto fcommit = []() { };
auto frollback = []() { };
auto fcommit = [] { };
auto frollback = [] { };
return match(tup.begin(), tup.end(), tarr.begin(), tarr.end(),
fpush, fcommit, frollback);
}
......
......@@ -47,9 +47,9 @@ namespace cppa { namespace detail {
namespace {
constexpr size_t s_alloc_size = 1024; // allocate ~1kb chunks
constexpr size_t s_alloc_size = 1024*1024; // allocate ~1mb chunks
constexpr size_t s_min_elements = 5; // don't create less than 5 elements
constexpr size_t s_cache_size = 10240; // cache about 10kb per thread
constexpr size_t s_cache_size = 10*1024*1024; // cache about 10mb per thread
} // namespace <anonymous>
......@@ -76,7 +76,7 @@ class memory_cache {
// calls dtor and either releases memory or re-uses it later
virtual void release_instance(void*) = 0;
virtual std::pair<instance_wrapper*,void*> new_instance() = 0;
virtual std::pair<instance_wrapper*, void*> new_instance() = 0;
// casts @p ptr to the derived type and returns it
virtual void* downcast(memory_managed* ptr) = 0;
......@@ -149,7 +149,7 @@ class basic_memory_cache : public memory_cache {
else wptr->deallocate();
}
virtual std::pair<instance_wrapper*,void*> new_instance() {
virtual std::pair<instance_wrapper*, void*> new_instance() {
if (cached_elements.empty()) {
auto elements = new storage;
for (auto i = elements->begin(); i != elements->end(); ++i) {
......
......@@ -93,7 +93,7 @@ struct pair_member_impl<T1, T2, false> {
};
template<typename T1, typename T2>
class pair_member : public util::abstract_uniform_type_info<std::pair<T1,T2>> {
class pair_member : public util::abstract_uniform_type_info<std::pair<T1, T2>> {
static_assert(util::is_builtin<T1>::value, "T1 is not a builtin type");
static_assert(util::is_builtin<T1>::value, "T2 is not a builtin type");
......
......@@ -36,10 +36,9 @@
#include "cppa/util/call.hpp"
#include "cppa/util/int_list.hpp"
#include "cppa/util/rm_option.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/left_or_right.hpp"
#include "cppa/util/get_result_type.hpp"
#include "cppa/detail/tdata.hpp"
......@@ -56,7 +55,7 @@ struct collected_args_tuple {
typename util::tl_zip<
typename util::tl_map<
ProjectionFuns,
util::get_result_type,
util::map_to_result_type,
util::rm_option
>::type,
typename util::tl_map<
......@@ -93,7 +92,7 @@ class projection {
*/
template<class PartFun>
bool invoke(PartFun& fun, typename PartFun::result_type& result, Ts... args) const {
typename collected_args_tuple<ProjectionFuns,Ts...>::type pargs;
typename collected_args_tuple<ProjectionFuns, Ts...>::type pargs;
if (collect(pargs, m_funs, std::forward<Ts>(args)...)) {
auto indices = util::get_indices(pargs);
if (is_defined_at(fun, pargs, indices)) {
......@@ -109,7 +108,7 @@ class projection {
*/
template<class PartFun>
bool operator()(PartFun& fun, Ts... args) const {
typename collected_args_tuple<ProjectionFuns,Ts...>::type pargs;
typename collected_args_tuple<ProjectionFuns, Ts...>::type pargs;
auto indices = util::get_indices(pargs);
if (collect(pargs, m_funs, std::forward<Ts>(args)...)) {
if (is_defined_at(fun, pargs, indices)) {
......
......@@ -32,7 +32,8 @@
#define CPPA_PSEUDO_TUPLE_HPP
#include <cstddef>
#include "cppa/util/at.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa { namespace detail {
......@@ -70,15 +71,15 @@ struct pseudo_tuple_from_type_list<util::type_list<Ts...> > {
namespace cppa {
template<size_t N, typename... Ts>
const typename util::at<N, Ts...>::type& get(const detail::pseudo_tuple<Ts...>& tv) {
const typename util::type_at<N, Ts...>::type& get(const detail::pseudo_tuple<Ts...>& tv) {
static_assert(N < sizeof...(Ts), "N >= tv.size()");
return *reinterpret_cast<const typename util::at<N, Ts...>::type*>(tv.at(N));
return *reinterpret_cast<const typename util::type_at<N, Ts...>::type*>(tv.at(N));
}
template<size_t N, typename... Ts>
typename util::at<N, Ts...>::type& get_ref(detail::pseudo_tuple<Ts...>& tv) {
typename util::type_at<N, Ts...>::type& get_ref(detail::pseudo_tuple<Ts...>& tv) {
static_assert(N < sizeof...(Ts), "N >= tv.size()");
return *reinterpret_cast<typename util::at<N, Ts...>::type*>(tv.mutable_at(N));
return *reinterpret_cast<typename util::type_at<N, Ts...>::type*>(tv.mutable_at(N));
}
} // namespace cppa
......
......@@ -39,7 +39,6 @@
#include "cppa/local_actor.hpp"
#include "cppa/partial_function.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp"
namespace cppa { namespace detail {
......
......@@ -63,7 +63,7 @@ class receive_policy {
public:
typedef mailbox_element* pointer;
typedef std::unique_ptr<mailbox_element,disposer> smart_pointer;
typedef std::unique_ptr<mailbox_element, disposer> smart_pointer;
enum handle_message_result {
hm_timeout_msg,
......@@ -77,7 +77,7 @@ class receive_policy {
bool invoke_from_cache(Client* client,
Fun& fun,
message_id awaited_response = message_id{}) {
std::integral_constant<receive_policy_flag,Client::receive_flag> policy;
std::integral_constant<receive_policy_flag, Client::receive_flag> policy;
auto i = m_cache.begin();
auto e = m_cache.end();
while (i != e) {
......@@ -110,7 +110,7 @@ class receive_policy {
Fun& fun,
message_id awaited_response = message_id()) {
smart_pointer node(node_ptr);
std::integral_constant<receive_policy_flag,Client::receive_flag> policy;
std::integral_constant<receive_policy_flag, Client::receive_flag> policy;
switch (this->handle_message(client, node.get(), fun,
awaited_response, policy)) {
case hm_msg_handled: {
......@@ -205,7 +205,7 @@ class receive_policy {
typedef typename rp_flag<rp_nestable>::type nestable;
typedef typename rp_flag<rp_sequential>::type sequential;
std::list<std::unique_ptr<mailbox_element,disposer> > m_cache;
std::list<std::unique_ptr<mailbox_element, disposer> > m_cache;
template<class Client>
inline void handle_timeout(Client* client, behavior& bhvr) {
......@@ -237,7 +237,7 @@ class receive_policy {
filter_result filter_msg(Client* client, pointer node) {
const any_tuple& msg = node->msg;
auto mid = node->mid;
auto& arr = detail::static_types_array<atom_value,std::uint32_t>::arr;
auto& arr = detail::static_types_array<atom_value, std::uint32_t>::arr;
if ( msg.size() == 2
&& msg.type_at(0) == arr[0]
&& msg.type_at(1) == arr[1]) {
......
......@@ -33,6 +33,7 @@
#include <cstdint>
#include "cppa/atom.hpp"
#include "cppa/actor.hpp"
#include "cppa/any_tuple.hpp"
#include "cppa/message_id.hpp"
......
......@@ -38,10 +38,10 @@
#include "cppa/get.hpp"
#include "cppa/option.hpp"
#include "cppa/util/at.hpp"
#include "cppa/util/wrapped.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/arg_match_t.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/rebindable_reference.hpp"
#include "cppa/detail/boxed.hpp"
......@@ -86,7 +86,7 @@ inline const uniform_type_info* utype_of(const T&) {
template<typename T>
inline const uniform_type_info* utype_of(const std::reference_wrapper<T>&) {
return static_types_array<typename util::rm_ref<T>::type>::arr[0];
return static_types_array<typename util::rm_const_and_ref<T>::type>::arr[0];
}
template<typename T>
......@@ -144,7 +144,7 @@ struct tdata<> {
// swallow any number of additional boxed or void_type arguments silently
template<typename... Ts>
tdata(Ts&&...) {
typedef util::type_list<typename util::rm_ref<Ts>::type...> incoming;
typedef util::type_list<typename util::rm_const_and_ref<Ts>::type...> incoming;
typedef typename util::tl_filter_not_type<incoming, tdata>::type iargs;
static_assert(util::tl_forall<iargs, boxed_or_void>::value,
"Additional unboxed arguments provided");
......@@ -212,16 +212,16 @@ template<typename Head, typename T>
auto td_filter(T&& arg)
-> decltype(
td_filter_<
is_boxed<typename util::rm_ref<T>::type>::value,
std::is_function<typename util::rm_ref<T>::type>::value,
is_boxed<typename util::rm_const_and_ref<T>::type>::value,
std::is_function<typename util::rm_const_and_ref<T>::type>::value,
Head,
typename util::rm_ref<T>::type
typename util::rm_const_and_ref<T>::type
>::_(std::forward<T>(arg))) {
return td_filter_<
is_boxed<typename util::rm_ref<T>::type>::value,
std::is_function<typename util::rm_ref<T>::type>::value,
is_boxed<typename util::rm_const_and_ref<T>::type>::value,
std::is_function<typename util::rm_const_and_ref<T>::type>::value,
Head,
typename util::rm_ref<T>::type
typename util::rm_const_and_ref<T>::type
>::_(std::forward<T>(arg));
}
......@@ -354,33 +354,33 @@ struct tdata<Head, Tail...> : tdata<Tail...> {
}
}
Head& _back(std::integral_constant<size_t,0>) {
Head& _back(std::integral_constant<size_t, 0>) {
return head;
}
template<size_t Pos>
back_type& _back(std::integral_constant<size_t,Pos>) {
std::integral_constant<size_t,Pos-1> token;
back_type& _back(std::integral_constant<size_t, Pos>) {
std::integral_constant<size_t, Pos-1> token;
return super::_back(token);
}
back_type& back() {
std::integral_constant<size_t,sizeof...(Tail)> token;
std::integral_constant<size_t, sizeof...(Tail)> token;
return _back(token);
}
const Head& _back(std::integral_constant<size_t,0>) const {
const Head& _back(std::integral_constant<size_t, 0>) const {
return head;
}
template<size_t Pos>
const back_type& _back(std::integral_constant<size_t,Pos>) const {
std::integral_constant<size_t,Pos-1> token;
const back_type& _back(std::integral_constant<size_t, Pos>) const {
std::integral_constant<size_t, Pos-1> token;
return super::_back(token);
}
const back_type& back() const {
std::integral_constant<size_t,sizeof...(Tail)> token;
std::integral_constant<size_t, sizeof...(Tail)> token;
return _back(token);
}
};
......@@ -444,13 +444,13 @@ void rebind_tdata(tdata<Ts...>& td, const tdata<Us...>& arg, const Vs&... args)
namespace cppa {
template<size_t N, typename... Ts>
const typename util::at<N, Ts...>::type& get(const detail::tdata<Ts...>& tv) {
const typename util::type_at<N, Ts...>::type& get(const detail::tdata<Ts...>& tv) {
static_assert(N < sizeof...(Ts), "N >= tv.size()");
return static_cast<const typename detail::tdata_upcast_helper<N, Ts...>::type&>(tv).head;
}
template<size_t N, typename... Ts>
typename util::at<N, Ts...>::type& get_ref(detail::tdata<Ts...>& tv) {
typename util::type_at<N, Ts...>::type& get_ref(detail::tdata<Ts...>& tv) {
static_assert(N < sizeof...(Ts), "N >= tv.size()");
return static_cast<typename detail::tdata_upcast_helper<N, Ts...>::type&>(tv).head;
}
......
......@@ -37,7 +37,7 @@
#include "cppa/primitive_type.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa { namespace detail {
......@@ -48,11 +48,11 @@ struct wrapped_ptype { static const primitive_type ptype = PT; };
template<typename T>
struct type_to_ptype_impl {
static constexpr primitive_type ptype =
std::is_convertible<T,std::string>::value
std::is_convertible<T, std::string>::value
? pt_u8string
: (std::is_convertible<T,std::u16string>::value
: (std::is_convertible<T, std::u16string>::value
? pt_u16string
: (std::is_convertible<T,std::u32string>::value
: (std::is_convertible<T, std::u32string>::value
? pt_u32string
: pt_null));
};
......@@ -73,7 +73,7 @@ template<> struct type_to_ptype_impl<double> : wrapped_ptype<pt_double
template<> struct type_to_ptype_impl<long double> : wrapped_ptype<pt_long_double> { };
template<typename T>
struct type_to_ptype : type_to_ptype_impl<typename util::rm_ref<T>::type> { };
struct type_to_ptype : type_to_ptype_impl<typename util::rm_const_and_ref<T>::type> { };
} } // namespace cppa::detail
......
......@@ -31,10 +31,11 @@
#ifndef CPPA_TYPES_ARRAY_HPP
#define CPPA_TYPES_ARRAY_HPP
#include <atomic>
#include <typeinfo>
#include "cppa/util/type_list.hpp"
#include "cppa/util/is_builtin.hpp"
#include "cppa/util/type_traits.hpp"
// forward declarations
namespace cppa {
......@@ -108,8 +109,8 @@ struct types_array_impl<false, T...> {
mutable std::atomic<const uniform_type_info* *> pairs;
// pairs[sizeof...(T)];
types_array_impl()
: tinfo_data{ta_util<std_tinf,util::is_builtin<T>::value,T>::get()...} {
bool static_init[sizeof...(T)] = { !std::is_same<T,anything>::value
: tinfo_data{ta_util<std_tinf, util::is_builtin<T>::value, T>::get()...} {
bool static_init[sizeof...(T)] = { !std::is_same<T, anything>::value
&& util::is_builtin<T>::value ... };
for (size_t i = 0; i < sizeof...(T); ++i) {
if (static_init[i]) {
......@@ -159,7 +160,7 @@ struct types_array : types_array_impl<util::tl_forall<util::type_list<T...>,
T...> {
static constexpr size_t size = sizeof...(T);
typedef util::type_list<T...> types;
typedef typename util::tl_filter_not<types, is_anything>::type
typedef typename util::tl_filter_not<types, util::is_anything>::type
filtered_types;
static constexpr size_t filtered_size = util::tl_size<filtered_types>::value;
inline bool has_values() const { return false; }
......
......@@ -71,7 +71,7 @@ using mapped_type_list = util::type_list<
std::string,
std::u16string,
std::u32string,
std::map<std::string,std::string>
std::map<std::string, std::string>
>;
using zipped_type_list = util::tl_zip_with_index<mapped_type_list>::type;
......@@ -81,7 +81,7 @@ extern const char* mapped_type_names[][2];
template<typename T>
constexpr const char* mapped_name() {
return mapped_type_names[util::tl_index_of<zipped_type_list,T>::value][1];
return mapped_type_names[util::tl_index_of<zipped_type_list, T>::value][1];
}
const char* mapped_name_by_decorated_name(const char* decorated_type_name);
......
......@@ -33,10 +33,9 @@
#include <type_traits>
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/void_type.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/detail/tdata.hpp"
......@@ -115,7 +114,7 @@ class value_guard {
template<typename T0, typename T1, typename... Ts,
typename U, typename... Us>
static inline bool _eval(const T0& head, const tdata<T1,Ts...>& tail,
static inline bool _eval(const T0& head, const tdata<T1, Ts...>& tail,
const U& arg, const Us&... args) {
return cmp(head, arg) && _eval(tail.head, tail.tail(), args...);
}
......
......@@ -53,7 +53,7 @@ class enable_weak_ptr : public Base {
template<typename T>
friend class weak_intrusive_ptr;
static_assert(std::is_base_of<ref_counted,Base>::value,
static_assert(std::is_base_of<ref_counted, Base>::value,
"Base needs to be derived from ref_counted");
protected:
......
......@@ -32,7 +32,7 @@
#define CPPA_MIXED_HPP
// saves some typing
#define CPPA_MIXIN template<class,class> class
#define CPPA_MIXIN template<class, class> class
namespace cppa {
......@@ -42,17 +42,17 @@ template<class D, class B, CPPA_MIXIN... Ms>
struct extend_helper;
template<class D, class B>
struct extend_helper<D,B> { typedef B type; };
struct extend_helper<D, B> { typedef B type; };
template<class D, class B, CPPA_MIXIN M, CPPA_MIXIN... Ms>
struct extend_helper<D,B,M,Ms...> : extend_helper<D,M<B,D>,Ms...> { };
struct extend_helper<D, B, M, Ms...> : extend_helper<D, M<B, D>, Ms...> { };
} // namespace detail
/**
* @brief Allows convenient definition of types using mixins.
* For example, @p extend<ar,T>::with<ob,fo> is an alias for
* @p fo<ob<ar,T>,T>.
* For example, @p extend<ar, T>::with<ob, fo> is an alias for
* @p fo<ob<ar, T>, T>.
*
* Mixins in libcppa always have two template parameters: base type and
* derived type. This allows mixins to make use of the curiously recurring
......@@ -64,8 +64,8 @@ struct extend {
/**
* @brief Identifies the combined type.
*/
template<template<class,class> class... Mixins>
using with = typename detail::extend_helper<Derived,Base,Mixins...>::type;
template<template<class, class> class... Mixins>
using with = typename detail::extend_helper<Derived, Base, Mixins...>::type;
};
} // namespace cppa
......
......@@ -34,7 +34,7 @@
#include <tuple>
#include <cstddef>
#include "cppa/util/at.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa {
......@@ -53,31 +53,31 @@ template<typename...> class cow_tuple;
// forward declaration of get(const detail::tdata<...>&)
template<size_t N, typename... Ts>
const typename util::at<N, Ts...>::type& get(const detail::tdata<Ts...>&);
const typename util::type_at<N, Ts...>::type& get(const detail::tdata<Ts...>&);
// forward declarations of get(const tuple<...>&)
template<size_t N, typename... Ts>
const typename util::at<N, Ts...>::type& get(const cow_tuple<Ts...>&);
const typename util::type_at<N, Ts...>::type& get(const cow_tuple<Ts...>&);
// forward declarations of get(detail::pseudo_tuple<...>&)
template<size_t N, typename... Ts>
const typename util::at<N, Ts...>::type& get(const detail::pseudo_tuple<Ts...>& tv);
const typename util::type_at<N, Ts...>::type& get(const detail::pseudo_tuple<Ts...>& tv);
// forward declarations of get(util::type_list<...>&)
template<size_t N, typename... Ts>
typename util::at<N, Ts...>::type get(const util::type_list<Ts...>&);
typename util::type_at<N, Ts...>::type get(const util::type_list<Ts...>&);
// forward declarations of get_ref(detail::tdata<...>&)
template<size_t N, typename... Ts>
typename util::at<N, Ts...>::type& get_ref(detail::tdata<Ts...>&);
typename util::type_at<N, Ts...>::type& get_ref(detail::tdata<Ts...>&);
// forward declarations of get_ref(tuple<...>&)
template<size_t N, typename... Ts>
typename util::at<N, Ts...>::type& get_ref(cow_tuple<Ts...>&);
typename util::type_at<N, Ts...>::type& get_ref(cow_tuple<Ts...>&);
// forward declarations of get_ref(detail::pseudo_tuple<...>&)
template<size_t N, typename... Ts>
typename util::at<N, Ts...>::type& get_ref(detail::pseudo_tuple<Ts...>& tv);
typename util::type_at<N, Ts...>::type& get_ref(detail::pseudo_tuple<Ts...>& tv);
// support get_ref access to std::tuple
template<size_t Pos, typename... Ts>
......
......@@ -40,10 +40,9 @@
#include "cppa/config.hpp"
#include "cppa/option.hpp"
#include "cppa/util/at.hpp"
#include "cppa/util/call.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/void_type.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/rebindable_reference.hpp"
#include "cppa/detail/tdata.hpp"
......@@ -215,7 +214,7 @@ struct ge_get_front {
>::type* = 0) const
-> option<
std::reference_wrapper<
const typename util::rm_ref<decltype(what.front())>::type> > {
const typename util::rm_const_and_ref<decltype(what.front())>::type> > {
if (what.empty() == false) return {what.front()};
return {};
}
......@@ -369,7 +368,7 @@ struct ge_unbound<guard_placeholder<X>, detail::tdata<Ts...> > {
static_assert(X < sizeof...(Ts),
"Cannot unbind placeholder (too few arguments)");
typedef typename ge_unbound<
typename util::at<X, Ts...>::type,
typename util::type_at<X, Ts...>::type,
detail::tdata<std::reference_wrapper<Ts>...>
>::type
type;
......@@ -477,9 +476,9 @@ struct ge_result_<guard_expr<exec_fun2_op, First, Second>, Tuple> {
template<typename First, typename Second, class Tuple>
struct ge_result_<guard_expr<exec_fun3_op, First, Second>, Tuple> {
typedef typename First::first_type type0;
typedef typename ge_unbound<typename First::second_type,Tuple>::type type1;
typedef typename ge_unbound<typename Second::first_type,Tuple>::type type2;
typedef typename ge_unbound<typename Second::second_type,Tuple>::type type3;
typedef typename ge_unbound<typename First::second_type, Tuple>::type type1;
typedef typename ge_unbound<typename Second::first_type, Tuple>::type type2;
typedef typename ge_unbound<typename Second::second_type, Tuple>::type type3;
typedef decltype( (*static_cast<const type0*>(nullptr))(
*static_cast<const type1*>(nullptr),
*static_cast<const type2*>(nullptr),
......@@ -661,9 +660,9 @@ ge_invoke_any(const guard_expr<OP, First, Second>& ge,
const any_tuple& tup) {
using namespace util;
typename std::conditional<
std::is_same<typename TupleTypes::back,anything>::value,
std::is_same<typename TupleTypes::back, anything>::value,
TupleTypes,
wrapped<typename tl_push_back<TupleTypes,anything>::type>
wrapped<typename tl_push_back<TupleTypes, anything>::type>
>::type
cast_token;
auto x = tuple_cast(tup, cast_token);
......@@ -684,7 +683,7 @@ bool guard_expr<OP, First, Second>::operator()(const Ts&... args) const {
template<typename T>
struct gref_wrapped {
typedef util::rebindable_reference<const typename util::rm_ref<T>::type> type;
typedef util::rebindable_reference<const typename util::rm_const_and_ref<T>::type> type;
};
template<typename T>
......
......@@ -46,7 +46,7 @@ class blocking_single_reader_queue {
public:
typedef single_reader_queue<T,Delete> impl_type;
typedef single_reader_queue<T, Delete> impl_type;
typedef typename impl_type::value_type value_type;
typedef typename impl_type::pointer pointer;
......
......@@ -209,13 +209,13 @@ inline bool operator!=(const intrusive_ptr<X>& lhs, const intrusive_ptr<Y>& rhs)
* of {@link ref_counted} and wraps it in an {@link intrusive_ptr}.
*/
template<typename T, typename... Ts>
typename std::enable_if<is_memory_cached<T>::value,intrusive_ptr<T>>::type
typename std::enable_if<is_memory_cached<T>::value, intrusive_ptr<T>>::type
make_counted(Ts&&... args) {
return {detail::memory::create<T>(std::forward<Ts>(args)...)};
}
template<typename T, typename... Ts>
typename std::enable_if<not is_memory_cached<T>::value,intrusive_ptr<T>>::type
typename std::enable_if<not is_memory_cached<T>::value, intrusive_ptr<T>>::type
make_counted(Ts&&... args) {
return {new T(std::forward<Ts>(args)...)};
}
......
......@@ -153,7 +153,7 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) {
#define CPPA_VOID_STMT static_cast<void>(0)
#define CPPA_CAT(a,b) a ## b
#define CPPA_CAT(a, b) a ## b
#define CPPA_ERROR 0
#define CPPA_WARNING 1
......
......@@ -57,7 +57,7 @@ class mailbox_based : public Base {
typedef mailbox_based combined_type;
typedef intrusive::single_reader_queue<mailbox_element,del> mailbox_type;
typedef intrusive::single_reader_queue<mailbox_element, del> mailbox_type;
template<typename... Ts>
mailbox_based(Ts&&... args) : Base(std::forward<Ts>(args)...) { }
......
......@@ -144,7 +144,7 @@ size_t run_case(std::vector<T>& vec,
template<size_t N, size_t Size>
struct unwind_and_call {
typedef unwind_and_call<N+1,Size> next;
typedef unwind_and_call<N+1, Size> next;
template<class Target, typename T, typename... Unwinded>
static inline bool _(Target& target, std::vector<T>& vec, Unwinded&&... args) {
......@@ -222,7 +222,7 @@ size_t run_case(std::vector<T>& vec,
typedef typename Case::second_type partial_fun_type;
typedef typename partial_fun_type::result_type result_type;
typedef typename partial_fun_type::arg_types arg_types;
typedef typename util::tl_map<arg_types, util::rm_ref>::type plain_args;
typedef typename util::tl_map<arg_types, util::rm_const_and_ref>::type plain_args;
static_assert(num_args > 0,
"empty match expressions are not allowed in stream matching");
static_assert(util::tl_forall<plain_args, util::tbind<std::is_same, T>::template type>::value,
......
This diff is collapsed.
......@@ -42,7 +42,7 @@
#include "cppa/message_id.hpp"
#include "cppa/local_actor.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa {
......
......@@ -65,14 +65,14 @@ class message_header {
template<typename T>
message_header(intrusive_ptr<T> dest)
: sender(self), receiver(dest), priority(message_priority::normal) {
static_assert(std::is_convertible<T*,channel*>::value,
static_assert(std::is_convertible<T*, channel*>::value,
"illegal receiver");
}
template<typename T>
message_header(T* dest)
: sender(self), receiver(dest), priority(message_priority::normal) {
static_assert(std::is_convertible<T*,channel*>::value,
static_assert(std::is_convertible<T*, channel*>::value,
"illegal receiver");
}
......
......@@ -44,7 +44,7 @@ namespace cppa { namespace network {
/**
* @brief A pair of input and output stream pointers.
*/
typedef std::pair<input_stream_ptr,output_stream_ptr> io_stream_ptr_pair;
typedef std::pair<input_stream_ptr, output_stream_ptr> io_stream_ptr_pair;
/**
* @brief Accepts connections from client processes.
......
......@@ -48,7 +48,7 @@ class default_actor_addressing : public actor_addressing {
default_actor_addressing(default_protocol* parent = nullptr);
typedef std::map<actor_id,weak_actor_proxy_ptr> proxy_map;
typedef std::map<actor_id, weak_actor_proxy_ptr> proxy_map;
atom_value technology_id() const;
......@@ -77,7 +77,7 @@ class default_actor_addressing : public actor_addressing {
default_protocol* m_parent;
process_information_ptr m_pinf;
std::map<process_information,proxy_map> m_proxies;
std::map<process_information, proxy_map> m_proxies;
};
......
......@@ -106,7 +106,7 @@ class default_actor_proxy : public actor_proxy {
default_protocol_ptr m_proto;
process_information_ptr m_pinf;
intrusive::single_reader_queue<sync_request_info,detail::disposer> m_pending_requests;
intrusive::single_reader_queue<sync_request_info, detail::disposer> m_pending_requests;
};
......
......@@ -41,7 +41,7 @@ class default_message_queue : public ref_counted {
public:
typedef std::pair<message_header,any_tuple> value_type;
typedef std::pair<message_header, any_tuple> value_type;
typedef value_type& reference;
......
......@@ -94,8 +94,8 @@ class default_protocol : public protocol {
};
default_actor_addressing m_addressing;
std::map<actor_ptr,std::vector<default_peer_acceptor_ptr> > m_acceptors;
std::map<process_information,peer_entry> m_peers;
std::map<actor_ptr, std::vector<default_peer_acceptor_ptr> > m_acceptors;
std::map<process_information, peer_entry> m_peers;
};
......
......@@ -195,7 +195,7 @@ class middleman_event_handler_base {
fd_meta_info_less m_less;
vector_type m_meta; // this vector is *always* sorted
std::vector<std::pair<fd_meta_info,fd_meta_event> > m_alterations;
std::vector<std::pair<fd_meta_info, fd_meta_event> > m_alterations;
private:
......@@ -257,14 +257,14 @@ class event_iterator_impl {
};
template<class Iter, class Access>
inline bool operator==(const event_iterator_impl<Iter,Access>& lhs,
const event_iterator_impl<Iter,Access>& rhs) {
inline bool operator==(const event_iterator_impl<Iter, Access>& lhs,
const event_iterator_impl<Iter, Access>& rhs) {
return lhs.equal_to(rhs);
}
template<class Iter, class Access>
inline bool operator!=(const event_iterator_impl<Iter,Access>& lhs,
const event_iterator_impl<Iter,Access>& rhs) {
inline bool operator!=(const event_iterator_impl<Iter, Access>& lhs,
const event_iterator_impl<Iter, Access>& rhs) {
return !lhs.equal_to(rhs);
}
......
......@@ -37,7 +37,7 @@
#include <type_traits>
#include "cppa/exception.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/detail/implicit_conversions.hpp"
namespace cppa {
......@@ -165,7 +165,7 @@ class object {
template<typename T>
object object::from(T what) {
typedef typename util::rm_ref<T>::type plain_type;
typedef typename util::rm_const_and_ref<T>::type plain_type;
typedef typename detail::implicit_conversions<plain_type>::type value_type;
auto rtti = uniform_typeid(typeid(value_type)); // throws on error
return { new value_type(std::move(what)), rtti };
......
......@@ -46,7 +46,7 @@
#include "cppa/util/duration.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/arg_match_t.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/detail/boxed.hpp"
#include "cppa/detail/unboxed.hpp"
......@@ -68,7 +68,7 @@ template<bool ToVoid, typename T>
struct to_void_impl { typedef util::void_type type; };
template<typename T>
struct to_void_impl<false,T> { typedef typename add_ptr_to_fun<T>::type type; };
struct to_void_impl<false, T> { typedef typename add_ptr_to_fun<T>::type type; };
template<typename T>
struct boxed_and_not_callable_to_void
......@@ -125,7 +125,7 @@ struct rvalue_builder {
typedef typename util::tl_back<Pattern>::type back_type;
static constexpr bool is_complete =
!std::is_same<util::arg_match_t,back_type>::value;
!std::is_same<util::arg_match_t, back_type>::value;
typedef typename util::tl_apply<Transformers, tdata>::type fun_container;
......@@ -201,13 +201,13 @@ struct pattern_type_ {
typedef util::get_callable_trait<T> ctrait;
typedef typename ctrait::arg_types args;
static_assert(util::tl_size<args>::value == 1, "only unary functions allowed");
typedef typename util::rm_ref<typename util::tl_head<args>::type>::type type;
typedef typename util::rm_const_and_ref<typename util::tl_head<args>::type>::type type;
};
template<typename T>
struct pattern_type_<false, T> {
typedef typename implicit_conversions<
typename util::rm_ref<
typename util::rm_const_and_ref<
typename detail::unboxed<T>::type
>::type
>::type
......@@ -303,7 +303,7 @@ detail::rvalue_builder<
typename util::tl_filter_not<
typename util::tl_trim<
typename util::tl_map<
util::type_list<T,Ts...>,
util::type_list<T, Ts...>,
detail::boxed_and_callable_to_void,
detail::implicit_conversions
>::type
......@@ -312,7 +312,7 @@ detail::rvalue_builder<
>::type
>,
typename util::tl_map<
util::type_list<T,Ts...>,
util::type_list<T, Ts...>,
detail::boxed_and_not_callable_to_void
>::type,
util::type_list<typename detail::pattern_type<T>::type,
......
......@@ -117,7 +117,7 @@ inline actor_ptr spawn_cl(const opencl::program& prog,
const opencl::dim_vec& local_dims = {}) {
typedef typename util::get_callable_trait<MapArgs>::fun_type f0;
typedef typename util::get_callable_trait<MapResult>::fun_type f1;
detail::cl_spawn_helper<f0,f1> f;
detail::cl_spawn_helper<f0, f1> f;
return f(prog, fname, dims, offset, local_dims,
f0{map_args}, f1{map_result});
}
......
......@@ -68,7 +68,7 @@ class actor_facade<Ret(Args...)> : public actor {
public:
typedef cow_tuple<typename util::rm_ref<Args>::type...> args_tuple;
typedef cow_tuple<typename util::rm_const_and_ref<Args>::type...> args_tuple;
typedef std::function<option<args_tuple>(any_tuple)> arg_mapping;
typedef std::function<any_tuple(Ret&)> result_mapping;
......
......@@ -89,7 +89,7 @@ class command_dispatcher {
const dim_vec& global_dims,
const dim_vec& offsets,
const dim_vec& local_dims,
std::function<option<cow_tuple<typename util::rm_ref<Args>::type...>>(any_tuple)> map_args,
std::function<option<cow_tuple<typename util::rm_const_and_ref<Args>::type...>>(any_tuple)> map_args,
std::function<any_tuple(Ret&)> map_result)
{
return actor_facade<Ret (Args...)>::create(this,
......@@ -109,14 +109,14 @@ class command_dispatcher {
const dim_vec& offsets = {},
const dim_vec& local_dims = {})
{
std::function<option<cow_tuple<typename util::rm_ref<Args>::type...>>(any_tuple)>
std::function<option<cow_tuple<typename util::rm_const_and_ref<Args>::type...>>(any_tuple)>
map_args = [] (any_tuple msg) {
return tuple_cast<typename util::rm_ref<Args>::type...>(msg);
return tuple_cast<typename util::rm_const_and_ref<Args>::type...>(msg);
};
std::function<any_tuple(Ret&)> map_result = [] (Ret& result) {
return make_any_tuple(std::move(result));
};
return this->spawn<Ret,Args...>(prog,
return this->spawn<Ret, Args...>(prog,
kernel_name,
global_dims,
offsets,
......@@ -149,7 +149,7 @@ class command_dispatcher {
, max_itms_per_dim(max_itms_per_dim) { }
};
typedef intrusive::blocking_single_reader_queue<command,dereferencer>
typedef intrusive::blocking_single_reader_queue<command, dereferencer>
job_queue;
static inline command_dispatcher* create_singleton() {
......
......@@ -47,7 +47,7 @@ namespace cppa { namespace opencl {
/**
* @brief A vector of up to three elements used for OpenCL dimensions.
*/
typedef util::limited_vector<size_t,3> dim_vec;
typedef util::limited_vector<size_t, 3> dim_vec;
std::string get_opencl_error(cl_int err);
......
......@@ -109,14 +109,14 @@ class smart_ptr {
};
typedef smart_ptr<cl_mem,clRetainMemObject,clReleaseMemObject> mem_ptr;
typedef smart_ptr<cl_event,clRetainEvent,clReleaseEvent> event_ptr;
typedef smart_ptr<cl_kernel,clRetainKernel,clReleaseKernel> kernel_ptr;
typedef smart_ptr<cl_context,clRetainContext,clReleaseContext> context_ptr;
typedef smart_ptr<cl_program,clRetainProgram,clReleaseProgram> program_ptr;
typedef smart_ptr<cl_device_id,clRetainDeviceDummy,clReleaseDeviceDummy>
typedef smart_ptr<cl_mem, clRetainMemObject, clReleaseMemObject> mem_ptr;
typedef smart_ptr<cl_event, clRetainEvent, clReleaseEvent> event_ptr;
typedef smart_ptr<cl_kernel, clRetainKernel, clReleaseKernel> kernel_ptr;
typedef smart_ptr<cl_context, clRetainContext, clReleaseContext> context_ptr;
typedef smart_ptr<cl_program, clRetainProgram, clReleaseProgram> program_ptr;
typedef smart_ptr<cl_device_id, clRetainDeviceDummy, clReleaseDeviceDummy>
device_ptr;
typedef smart_ptr<cl_command_queue,clRetainCommandQueue,clReleaseCommandQueue>
typedef smart_ptr<cl_command_queue, clRetainCommandQueue, clReleaseCommandQueue>
command_queue_ptr;
} } // namespace cppa::opencl
......
......@@ -82,7 +82,7 @@ struct option_info {
/**
* @brief Stores a help text for program options with option groups.
*/
typedef std::map<std::string,std::map<std::pair<char,std::string>,option_info> >
typedef std::map<std::string, std::map<std::pair<char, std::string>, option_info> >
options_description;
/**
......
......@@ -107,7 +107,7 @@ class partial_function {
*/
template<typename... Ts>
typename std::conditional<
util::disjunction<util::rm_ref<Ts>::type::may_have_timeout...>::value,
util::disjunction<util::rm_const_and_ref<Ts>::type::may_have_timeout...>::value,
behavior,
partial_function
>::type
......@@ -120,7 +120,7 @@ class partial_function {
};
template<typename T>
typename std::conditional<T::may_have_timeout,behavior,partial_function>::type
typename std::conditional<T::may_have_timeout, behavior, partial_function>::type
match_expr_convert(const T& arg) {
return {arg};
}
......@@ -163,7 +163,7 @@ inline bool partial_function::operator()(T&& arg) {
template<typename... Ts>
typename std::conditional<
util::disjunction<util::rm_ref<Ts>::type::may_have_timeout...>::value,
util::disjunction<util::rm_const_and_ref<Ts>::type::may_have_timeout...>::value,
behavior,
partial_function
>::type
......
......@@ -41,7 +41,7 @@
#include "cppa/util/pt_token.hpp"
#include "cppa/util/pt_dispatch.hpp"
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/detail/type_to_ptype.hpp"
#include "cppa/detail/ptype_to_type.hpp"
......
......@@ -44,8 +44,8 @@ namespace cppa {
/**
* @brief Identifies a process.
*/
class process_information : public ref_counted,
util::comparable<process_information> {
class process_information : public ref_counted
, util::comparable<process_information> {
typedef ref_counted super;
......
......@@ -48,7 +48,7 @@ namespace cppa {
template<class Derived, class Base = event_based_actor>
class sb_actor : public Base {
static_assert(std::is_base_of<event_based_actor,Base>::value,
static_assert(std::is_base_of<event_based_actor, Base>::value,
"Base must be either event_based_actor or a derived type");
protected:
......
......@@ -158,7 +158,7 @@ class scheduled_actor : public extend<local_actor>::with<mailbox_based>{
void cleanup(std::uint32_t reason) override;
typedef intrusive::single_reader_queue<mailbox_element,detail::disposer>
typedef intrusive::single_reader_queue<mailbox_element, detail::disposer>
mailbox_type;
actor_state compare_exchange_state(actor_state expected, actor_state desired);
......
......@@ -57,8 +57,8 @@ namespace detail { class singleton_manager; } // namespace detail
namespace detail {
template<typename T>
struct is_self {
typedef typename util::rm_ref<T>::type plain_type;
static constexpr bool value = std::is_same<plain_type,self_type>::value;
typedef typename util::rm_const_and_ref<T>::type plain_type;
static constexpr bool value = std::is_same<plain_type, self_type>::value;
};
template<typename T, typename U>
auto fwd(U& arg, typename std::enable_if<!is_self<T>::value>::type* = 0)
......
......@@ -161,7 +161,7 @@ inline message_future sync_send(actor_ptr whom, Ts&&... what) {
*/
template<class Rep, class Period, typename... Ts>
message_future timed_sync_send_tuple(actor_ptr whom,
const std::chrono::duration<Rep,Period>& rel_time,
const std::chrono::duration<Rep, Period>& rel_time,
any_tuple what) {
auto mf = sync_send_tuple(std::move(whom), std::move(what));
auto tmp = make_any_tuple(atom("TIMEOUT"));
......@@ -185,7 +185,7 @@ message_future timed_sync_send_tuple(actor_ptr whom,
*/
template<class Rep, class Period, typename... Ts>
message_future timed_sync_send(actor_ptr whom,
const std::chrono::duration<Rep,Period>& rel_time,
const std::chrono::duration<Rep, Period>& rel_time,
Ts&&... what) {
static_assert(sizeof...(Ts) > 0, "no message to send");
return timed_sync_send_tuple(std::move(whom),
......@@ -245,7 +245,7 @@ inline void forward_to(const actor_ptr& whom) {
*/
template<class Rep, class Period, typename... Ts>
inline void delayed_send_tuple(const channel_ptr& whom,
const std::chrono::duration<Rep,Period>& rtime,
const std::chrono::duration<Rep, Period>& rtime,
any_tuple what) {
if (whom) get_scheduler()->delayed_send(whom, rtime, what);
}
......@@ -259,7 +259,7 @@ inline void delayed_send_tuple(const channel_ptr& whom,
*/
template<class Rep, class Period, typename... Ts>
inline void delayed_send(const channel_ptr& whom,
const std::chrono::duration<Rep,Period>& rtime,
const std::chrono::duration<Rep, Period>& rtime,
Ts&&... what) {
static_assert(sizeof...(Ts) > 0, "no message to send");
if (whom) {
......
......@@ -63,8 +63,8 @@ class scheduler_helper;
* @brief An actor using the blocking API running in its own thread.
* @extends local_actor
*/
class thread_mapped_actor : public extend<local_actor,thread_mapped_actor>::
with<mailbox_based,stacked,threaded> {
class thread_mapped_actor : public extend<local_actor, thread_mapped_actor>::
with<mailbox_based, stacked, threaded> {
typedef combined_type super;
......
......@@ -35,11 +35,9 @@
#include <type_traits>
#include "cppa/util/call.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/left_or_right.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/util/is_mutable_ref.hpp"
namespace cppa {
......
......@@ -41,7 +41,7 @@
#include "cppa/object.hpp"
#include "cppa/util/comparable.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/detail/demangle.hpp"
#include "cppa/detail/to_uniform_name.hpp"
......@@ -91,7 +91,7 @@ const uniform_type_info* uniform_typeid(const std::type_info&);
*
* int main()
* {
* send(self, foo{1,2});
* send(self, foo{1, 2});
* return 0;
* }
* @endcode
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_AT_HPP
#define CPPA_AT_HPP
namespace cppa { namespace util {
template<size_t N, typename... Ts>
struct at;
template<size_t N, typename T0, typename... Ts>
struct at<N, T0, Ts...> {
typedef typename at<N-1, Ts...>::type type;
};
template<typename T0, typename... Ts>
struct at<0, T0, Ts...> {
typedef T0 type;
};
} } // namespace cppa::util
#endif // CPPA_AT_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_UTIL_CALLABLE_TRAIT
#define CPPA_UTIL_CALLABLE_TRAIT
#include <functional>
#include <type_traits>
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/type_list.hpp"
namespace cppa { namespace util {
template<typename Signature>
struct callable_trait;
// member const function pointer
template<class C, typename Result, typename... Ts>
struct callable_trait<Result (C::*)(Ts...) const> {
typedef Result result_type;
typedef type_list<Ts...> arg_types;
typedef std::function<Result (Ts...)> fun_type;
};
// member function pointer
template<class C, typename Result, typename... Ts>
struct callable_trait<Result (C::*)(Ts...)> {
typedef Result result_type;
typedef type_list<Ts...> arg_types;
typedef std::function<Result (Ts...)> fun_type;
};
// good ol' function
template<typename Result, typename... Ts>
struct callable_trait<Result (Ts...)> {
typedef Result result_type;
typedef type_list<Ts...> arg_types;
typedef std::function<Result (Ts...)> fun_type;
};
// good ol' function pointer
template<typename Result, typename... Ts>
struct callable_trait<Result (*)(Ts...)> {
typedef Result result_type;
typedef type_list<Ts...> arg_types;
typedef std::function<Result (Ts...)> fun_type;
};
// matches (IsFun || IsMemberFun)
template<bool IsFun, bool IsMemberFun, typename T>
struct get_callable_trait_helper {
typedef callable_trait<T> type;
};
// assume functor providing operator()
template<typename C>
struct get_callable_trait_helper<false, false, C> {
typedef callable_trait<decltype(&C::operator())> type;
};
template<typename T>
struct get_callable_trait {
// type without cv qualifiers
typedef typename rm_ref<T>::type bare_type;
// if type is a function pointer, this typedef identifies the function
typedef typename std::remove_pointer<bare_type>::type signature_type;
typedef typename get_callable_trait_helper<
std::is_function<bare_type>::value
|| std::is_function<signature_type>::value,
std::is_member_function_pointer<bare_type>::value,
bare_type
>::type
type;
typedef typename type::result_type result_type;
typedef typename type::arg_types arg_types;
typedef typename type::fun_type fun_type;
};
template<typename C>
struct get_arg_types {
typedef typename get_callable_trait<C>::type trait_type;
typedef typename trait_type::arg_types types;
};
} } // namespace cppa::util
#endif // CPPA_UTIL_CALLABLE_TRAIT
......@@ -32,14 +32,14 @@
#define CPPA_COMPARE_TUPLES_HPP
#include "cppa/get.hpp"
#include "cppa/util/at.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/is_comparable.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa { namespace detail {
template<size_t N, template<typename...> class Tuple, typename... Ts>
const typename util::at<N, Ts...>::type&
const typename util::type_at<N, Ts...>::type&
do_get(const Tuple<Ts...>& t) {
return ::cppa::get<N, Ts...>(t);
}
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_CONJUNCTION_HPP
#define CPPA_CONJUNCTION_HPP
#include <type_traits>
namespace cppa { namespace util {
template<typename... BooleanConstants>
struct conjunction;
template<>
struct conjunction<> : std::false_type { };
template<typename T0>
struct conjunction<T0> {
static constexpr bool value = T0::value;
};
template<typename T0, typename T1, typename... Ts>
struct conjunction<T0,T1,Ts...> {
static constexpr bool value = T0::value && conjunction<T1,Ts...>::value;
};
} } // namespace cppa::util
#endif // CPPA_CONJUNCTION_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_DEDUCE_REF_TYPE_HPP
#define CPPA_DEDUCE_REF_TYPE_HPP
#include "cppa/util/rm_ref.hpp"
namespace cppa { namespace util {
/**
* @brief Deduces reference type of T0 and applies it to T1.
*/
template<typename T0, typename T1>
struct deduce_ref_type {
typedef typename util::rm_ref<T1>::type type;
};
template<typename T0, typename T1>
struct deduce_ref_type<T0&, T1> {
typedef typename util::rm_ref<T1>::type& type;
};
template<typename T0, typename T1>
struct deduce_ref_type<const T0&, T1> {
typedef const typename util::rm_ref<T1>::type& type;
};
} } // namespace cppa::util
#endif // CPPA_DEDUCE_REF_TYPE_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_DISJUNCTION_HPP
#define CPPA_DISJUNCTION_HPP
#include <type_traits>
namespace cppa { namespace util {
template<bool... Values>
struct disjunction;
template<bool Head, bool... Tail>
struct disjunction<Head, Tail...>
: std::integral_constant<bool, Head || disjunction<Tail...>::value> {
};
template<>
struct disjunction<> : std::false_type { };
} } // namespace cppa::util
#endif // CPPA_DISJUNCTION_HPP
......@@ -41,13 +41,13 @@ namespace cppa { namespace util {
*/
template<class Subtype, class MixinType>
typename std::conditional<
std::is_base_of<MixinType,Subtype>::value,
std::is_base_of<MixinType, Subtype>::value,
Subtype,
MixinType
>::type*
dptr(MixinType* ptr) {
typedef typename std::conditional<
std::is_base_of<MixinType,Subtype>::value,
std::is_base_of<MixinType, Subtype>::value,
Subtype,
MixinType
>::type
......
......@@ -83,7 +83,7 @@ class duration {
}
template<class Rep>
constexpr duration(std::chrono::duration<Rep, std::ratio<60,1> > d)
constexpr duration(std::chrono::duration<Rep, std::ratio<60, 1> > d)
: unit(time_unit::seconds), count(d.count() * 60) { }
/**
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_ELEMENT_AT_HPP
#define CPPA_ELEMENT_AT_HPP
#include "cppa/util/at.hpp"
namespace cppa { namespace util {
template<size_t N, class C>
struct element_at;
/**
* @brief Returns the n-th template parameter of @p C.
*/
template<size_t N, template<typename...> class C, typename... Ts>
struct element_at<N, C<Ts...>> : at<N, Ts...> {
};
} } // namespace cppa::util
#endif // CPPA_ELEMENT_AT_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_GET_RESULT_TYPE_HPP
#define CPPA_GET_RESULT_TYPE_HPP
#include "cppa/util/is_callable.hpp"
#include "cppa/util/callable_trait.hpp"
namespace cppa { namespace util {
template<bool IsCallable, typename C>
struct get_result_type_impl {
typedef typename get_callable_trait<C>::type trait_type;
typedef typename trait_type::result_type type;
};
template<typename C>
struct get_result_type_impl<false, C> {
typedef void_type type;
};
template<typename C>
struct get_result_type {
typedef typename get_result_type_impl<is_callable<C>::value, C>::type type;
};
} } // namespace cppa::util
#endif // CPPA_GET_RESULT_TYPE_HPP
......@@ -35,10 +35,6 @@
namespace cppa { namespace util {
/**
* @defgroup MetaProgramming Metaprogramming utility.
*/
/**
* @addtogroup MetaProgramming
* @{
......@@ -74,7 +70,7 @@ template<class List>
struct il_head;
template<long I0, long... Is>
struct il_head<int_list<I0,Is...>> {
struct il_head<int_list<I0, Is...>> {
static constexpr long value = I0;
};
......@@ -93,7 +89,7 @@ struct il_tail<empty_int_list> {
};
template<long I0, long... Is>
struct il_tail<int_list<I0,Is...>> {
struct il_tail<int_list<I0, Is...>> {
typedef int_list<Is...> type;
};
......@@ -125,8 +121,8 @@ struct il_back<int_list<I0>> {
};
template<long I0, long I1, long... Is>
struct il_back<int_list<I0,I1,Is...> > {
static constexpr long value = il_back<int_list<I1,Is...>>::value;
struct il_back<int_list<I0, I1, Is...> > {
static constexpr long value = il_back<int_list<I1, Is...>>::value;
};
......@@ -137,7 +133,7 @@ struct il_back<int_list<I0,I1,Is...> > {
*/
template<class List>
struct il_empty {
static constexpr bool value = std::is_same<empty_int_list,List>::value;
static constexpr bool value = std::is_same<empty_int_list, List>::value;
};
......@@ -153,8 +149,8 @@ struct il_min<int_list<I0>> {
};
template<long I0, long I1, long... Is>
struct il_min<int_list<I0,I1,Is...> > {
static constexpr long value = il_min<int_list<(I0 < I1) ? I0 : I1,Is...>>::value;
struct il_min<int_list<I0, I1, Is...> > {
static constexpr long value = il_min<int_list<(I0 < I1) ? I0 : I1, Is...>>::value;
};
......@@ -170,8 +166,8 @@ struct il_max<int_list<I0>> {
};
template<long I0, long I1, long... Is>
struct il_max<int_list<I0,I1,Is...> > {
static constexpr long value = il_max<int_list<(I0 > I1) ? I0 : I1,Is...>>::value;
struct il_max<int_list<I0, I1, Is...> > {
static constexpr long value = il_max<int_list<(I0 > I1) ? I0 : I1, Is...>>::value;
};
......@@ -228,11 +224,11 @@ struct il_slice_impl<0, 0, PadValue, empty_int_list, Is...> {
template<class List, size_t ListSize, size_t First, size_t Last, long PadValue = 0>
struct il_slice_ {
typedef typename il_slice_impl<First,(Last-First),PadValue,List>::type type;
typedef typename il_slice_impl<First, (Last-First), PadValue, List>::type type;
};
template<class List, size_t ListSize, long PadValue>
struct il_slice_<List,ListSize,0,ListSize,PadValue> {
struct il_slice_<List, ListSize, 0, ListSize, PadValue> {
typedef List type;
};
......@@ -242,7 +238,7 @@ struct il_slice_<List,ListSize,0,ListSize,PadValue> {
template<class List, size_t First, size_t Last>
struct il_slice {
static_assert(First <= Last, "First > Last");
typedef typename il_slice_<List,il_size<List>::value,First,Last>::type type;
typedef typename il_slice_<List, il_size<List>::value, First, Last>::type type;
};
/**
......@@ -252,11 +248,11 @@ template<class List, size_t N>
struct il_right {
static constexpr size_t list_size = il_size<List>::value;
static constexpr size_t first_idx = (list_size > N) ? (list_size - N) : 0;
typedef typename il_slice<List,first_idx,list_size>::type type;
typedef typename il_slice<List, first_idx, list_size>::type type;
};
template<size_t N>
struct il_right<empty_int_list,N> {
struct il_right<empty_int_list, N> {
typedef empty_int_list type;
};
......@@ -266,12 +262,12 @@ template<class List, long... Vs>
struct il_reverse_impl;
template<long I0, long... Is, long... Vs>
struct il_reverse_impl<int_list<I0,Is...>,Vs...> {
typedef typename il_reverse_impl<int_list<Is...>,I0,Vs...>::type type;
struct il_reverse_impl<int_list<I0, Is...>, Vs...> {
typedef typename il_reverse_impl<int_list<Is...>, I0, Vs...>::type type;
};
template<long... Vs>
struct il_reverse_impl<empty_int_list,Vs...> {
struct il_reverse_impl<empty_int_list, Vs...> {
typedef int_list<Vs...> type;
};
......@@ -288,8 +284,8 @@ template<class List1, class List2>
struct il_concat_impl;
template<long... As, long... Bs>
struct il_concat_impl<int_list<As...>,int_list<Bs...>> {
typedef int_list<As...,Bs...> type;
struct il_concat_impl<int_list<As...>, int_list<Bs...>> {
typedef int_list<As..., Bs...> type;
};
// static list concat(list, list)
......@@ -306,9 +302,9 @@ struct il_concat<List0> {
};
template<class List0, class List1, class... Lists>
struct il_concat<List0,List1,Lists...> {
struct il_concat<List0, List1, Lists...> {
typedef typename il_concat<
typename il_concat_impl<List0,List1>::type,
typename il_concat_impl<List0, List1>::type,
Lists...
>::type
type;
......@@ -323,8 +319,8 @@ struct il_push_back;
* @brief Appends @p What to given list.
*/
template<long... Is, long Val>
struct il_push_back<int_list<Is...>,Val> {
typedef int_list<Is...,Val> type;
struct il_push_back<int_list<Is...>, Val> {
typedef int_list<Is..., Val> type;
};
template<class List, long Val>
......@@ -334,8 +330,8 @@ struct il_push_front;
* @brief Appends @p What to given list.
*/
template<long... Is, long Val>
struct il_push_front<int_list<Is...>,Val> {
typedef int_list<Val,Is...> type;
struct il_push_front<int_list<Is...>, Val> {
typedef int_list<Val, Is...> type;
};
......@@ -346,7 +342,7 @@ struct il_push_front<int_list<Is...>,Val> {
*/
template<class List>
struct il_pop_back {
typedef typename il_slice<List,0,il_size<List>::value-1>::type type;
typedef typename il_slice<List, 0, il_size<List>::value-1>::type type;
};
template<>
......@@ -360,10 +356,10 @@ template<size_t N, long... Is>
struct il_at_impl;
template<size_t N, long I0, long... Is>
struct il_at_impl<N,I0,Is...> : il_at_impl<N-1,Is...> { };
struct il_at_impl<N, I0, Is...> : il_at_impl<N-1, Is...> { };
template<long I0, long... Is>
struct il_at_impl<0,I0,Is...> {
struct il_at_impl<0, I0, Is...> {
static constexpr long value = I0;
};
......@@ -388,8 +384,8 @@ struct il_prepend;
* @brief Creates a new list with @p What prepended to @p List.
*/
template<long Val, long... Is>
struct il_prepend<int_list<Is...>,Val> {
typedef int_list<Val,Is...> type;
struct il_prepend<int_list<Is...>, Val> {
typedef int_list<Val, Is...> type;
};
// list resize(list, size, fill_type)
......@@ -399,12 +395,12 @@ template<class List, bool OldSizeLessNewSize,
struct il_pad_right_impl;
template<class List, size_t OldSize, size_t NewSize, long FillVal>
struct il_pad_right_impl<List,false,OldSize,NewSize,FillVal> {
typedef typename il_slice<List,0,NewSize>::type type;
struct il_pad_right_impl<List, false, OldSize, NewSize, FillVal> {
typedef typename il_slice<List, 0, NewSize>::type type;
};
template<class List, size_t Size, long FillVal>
struct il_pad_right_impl<List,false,Size,Size,FillVal> {
struct il_pad_right_impl<List, false, Size, Size, FillVal> {
typedef List type;
};
......@@ -470,12 +466,12 @@ struct il_pad_left {
*/
template<long From, long To, long... Is>
struct il_range {
typedef typename il_range<From,To-1,To,Is...>::type type;
typedef typename il_range<From, To-1, To, Is...>::type type;
};
template<long X, long... Is>
struct il_range<X,X,Is...> {
typedef int_list<X,Is...> type;
struct il_range<X, X, Is...> {
typedef int_list<X, Is...> type;
};
/**
......@@ -485,14 +481,14 @@ template<typename List, long Pos = 0, typename Indices = empty_int_list>
struct il_indices;
template<template<class...> class List, long... Is, long Pos>
struct il_indices<List<>,Pos,int_list<Is...>> {
struct il_indices<List<>, Pos, int_list<Is...>> {
typedef int_list<Is...> type;
};
template<template<class...> class List, typename T0, typename... Ts, long Pos, long... Is>
struct il_indices<List<T0,Ts...>,Pos,int_list<Is...>> {
struct il_indices<List<T0, Ts...>, Pos, int_list<Is...>> {
// always use type_list to forward remaining Ts... arguments
typedef typename il_indices<type_list<Ts...>,Pos+1,int_list<Is...,Pos>>::type type;
typedef typename il_indices<type_list<Ts...>, Pos+1, int_list<Is..., Pos>>::type type;
};
template<typename T>
......@@ -502,7 +498,7 @@ constexpr auto get_indices(const T&) -> typename il_indices<T>::type {
template<size_t Num, typename T>
constexpr auto get_right_indices(const T&)
-> typename il_right<typename il_indices<T>::type,Num>::type {
-> typename il_right<typename il_indices<T>::type, Num>::type {
return {};
}
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_ARRAY_OF_HPP
#define CPPA_IS_ARRAY_OF_HPP
#include <type_traits>
namespace cppa { namespace util {
/**
* @ingroup MetaProgramming
* @brief <tt>is_array_of<T,U>::value == true</tt> if and only
* if @p T is an array of @p U.
*/
template<typename T, typename U>
struct is_array_of {
typedef typename std::remove_all_extents<T>::type step1_type;
typedef typename std::remove_cv<step1_type>::type step2_type;
static constexpr bool value = std::is_array<T>::value
&& std::is_same<step2_type, U>::value;
};
} } // namespace cppa::util
#endif // CPPA_IS_ARRAY_OF_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_BUILTIN_HPP
#define CPPA_IS_BUILTIN_HPP
#include <string>
#include <type_traits>
#include "cppa/atom.hpp"
#include "cppa/actor.hpp"
#include "cppa/group.hpp"
#include "cppa/channel.hpp"
#include "cppa/anything.hpp"
#include "cppa/intrusive_ptr.hpp"
#include "cppa/process_information.hpp"
namespace cppa { class any_tuple; }
namespace cppa { class message_header; }
namespace cppa { namespace util {
template<typename T>
struct is_builtin {
static constexpr bool value = std::is_arithmetic<T>::value;
};
template<>
struct is_builtin<anything> : std::true_type { };
template<>
struct is_builtin<std::string> : std::true_type { };
template<>
struct is_builtin<std::u16string> : std::true_type { };
template<>
struct is_builtin<std::u32string> : std::true_type { };
template<>
struct is_builtin<atom_value> : std::true_type { };
template<>
struct is_builtin<any_tuple> : std::true_type { };
template<>
struct is_builtin<message_header> : std::true_type { };
template<>
struct is_builtin<actor_ptr> : std::true_type { };
template<>
struct is_builtin<group_ptr> : std::true_type { };
template<>
struct is_builtin<channel_ptr> : std::true_type { };
template<>
struct is_builtin<intrusive_ptr<process_information> > : std::true_type { };
} } // namespace cppa::util
#endif // CPPA_IS_BUILTIN_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_CALLABLE_HPP
#define CPPA_IS_CALLABLE_HPP
#include "cppa/util/conjunction.hpp"
#include "cppa/util/callable_trait.hpp"
namespace cppa { namespace util {
template<typename T>
struct is_callable {
template<typename C>
static bool _fun(C*, typename callable_trait<C>::result_type* = nullptr) {
return true;
}
template<typename C>
static bool _fun(C*, typename callable_trait<decltype(&C::operator())>::result_type* = nullptr) {
return true;
}
static void _fun(void*) { }
typedef decltype(_fun(static_cast<typename rm_ref<T>::type*>(nullptr)))
result_type;
public:
static constexpr bool value = std::is_same<bool, result_type>::value;
};
template<typename... Ts>
struct all_callable {
static constexpr bool value = conjunction<is_callable<Ts>...>::value;
};
} } // namespace cppa::util
#endif // CPPA_IS_CALLABLE_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_COMPARABLE_HPP
#define CPPA_IS_COMPARABLE_HPP
#include <type_traits>
namespace cppa { namespace util {
template<typename T1, typename T2>
class is_comparable {
// SFINAE: If you pass a "bool*" as third argument, then
// decltype(cmp_help_fun(...)) is bool if there's an
// operator==(A,B) because
// cmp_help_fun(A*, B*, bool*) is a better match than
// cmp_help_fun(A*, B*, void*). If there's no operator==(A,B)
// available, then cmp_help_fun(A*, B*, void*) is the only
// candidate and thus decltype(cmp_help_fun(...)) is void.
template<typename A, typename B>
static bool cmp_help_fun(const A* arg0, const B* arg1,
decltype(*arg0 == *arg1)* = nullptr) {
return true;
}
template<typename A, typename B>
static void cmp_help_fun(const A*, const B*, void* = nullptr) { }
typedef decltype(cmp_help_fun(static_cast<T1*>(nullptr),
static_cast<T2*>(nullptr),
static_cast<bool*>(nullptr)))
result_type;
public:
static constexpr bool value = std::is_same<bool, result_type>::value;
};
} } // namespace cppa::util
#endif // CPPA_IS_COMPARABLE_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_FORWARD_ITERATOR_HPP
#define CPPA_IS_FORWARD_ITERATOR_HPP
#include <type_traits>
#include "cppa/util/rm_ref.hpp"
namespace cppa { namespace util {
/**
* @ingroup MetaProgramming
* @brief Checks wheter @p T behaves like a forward iterator.
*/
template<typename T>
class is_forward_iterator {
template<class C>
static bool sfinae_fun (
C* iter,
// check for 'C::value_type C::operator*()' returning a non-void type
typename rm_ref<decltype(*(*iter))>::type* = 0,
// check for 'C& C::operator++()'
typename std::enable_if<std::is_same<C&, decltype(++(*iter))>::value>::type* = 0,
// check for 'bool C::operator==()'
typename std::enable_if<std::is_same<bool, decltype(*iter == *iter)>::value>::type* = 0,
// check for 'bool C::operator!=()'
typename std::enable_if<std::is_same<bool, decltype(*iter != *iter)>::value>::type* = 0
) {
return true;
}
static void sfinae_fun(void*) { }
typedef decltype(sfinae_fun(static_cast<T*>(nullptr))) result_type;
public:
static constexpr bool value = std::is_same<bool, result_type>::value;
};
} } // namespace cppa::util
#endif // CPPA_IS_FORWARD_ITERATOR_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_ITERABLE_HPP
#define CPPA_IS_ITERABLE_HPP
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/is_forward_iterator.hpp"
namespace cppa { namespace util {
/**
* @ingroup MetaProgramming
* @brief Checks wheter @p T has <tt>begin()</tt> and <tt>end()</tt> member
* functions returning forward iterators.
*/
template<typename T>
class is_iterable {
// this horrible code would just disappear if we had concepts
template<class C>
static bool sfinae_fun (
const C* cc,
// check for 'C::begin()' returning a forward iterator
typename std::enable_if<util::is_forward_iterator<decltype(cc->begin())>::value>::type* = 0,
// check for 'C::end()' returning the same kind of forward iterator
typename std::enable_if<std::is_same<decltype(cc->begin()), decltype(cc->end())>::value>::type* = 0
) {
return true;
}
// SFNINAE default
static void sfinae_fun(const void*) { }
typedef decltype(sfinae_fun(static_cast<const T*>(nullptr))) result_type;
public:
static constexpr bool value = util::is_primitive<T>::value == false
&& std::is_same<bool, result_type>::value;
};
} } // namespace cppa::util
#endif // CPPA_IS_ITERABLE_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_LEGAL_TUPLE_TYPE_HPP
#define CPPA_IS_LEGAL_TUPLE_TYPE_HPP
#include <type_traits>
namespace cppa { namespace util {
/**
* @ingroup MetaProgramming
* @brief Checks wheter @p T is neither a reference nor a pointer nor an array.
*/
template<typename T>
struct is_legal_tuple_type {
static constexpr bool value = std::is_reference<T>::value == false
&& std::is_pointer<T>::value == false
&& std::is_array<T>::value == false;
};
} } // namespace cppa::util
#endif // CPPA_IS_LEGAL_TUPLE_TYPE_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_MANIPULATOR_HPP
#define CPPA_IS_MANIPULATOR_HPP
#include "cppa/util/type_list.hpp"
#include "cppa/util/is_mutable_ref.hpp"
#include "cppa/util/callable_trait.hpp"
namespace cppa { namespace util {
// A manipulator is a function that manipulates its arguments via
// mutable references.
/**
* @ingroup MetaProgramming
* @brief Checks wheter functor or function @p F takes mutable references.
*/
template<typename F>
struct is_manipulator {
static constexpr bool value =
tl_exists<typename get_arg_types<F>::types, is_mutable_ref>::value;
};
} } // namespace cppa::util
#endif // CPPA_IS_MANIPULATOR_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_MUTABLE_REF_HPP
#define CPPA_IS_MUTABLE_REF_HPP
namespace cppa { namespace util {
/**
* @brief Checks wheter @p T is a non-const reference.
*/
template<typename T>
struct is_mutable_ref {
static constexpr bool value = false;
};
template<typename T>
struct is_mutable_ref<const T&> {
static constexpr bool value = false;
};
template<typename T>
struct is_mutable_ref<T&> {
static constexpr bool value = true;
};
} } // namespace cppa::util
#endif // CPPA_IS_MUTABLE_REF_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_IS_PRIMITIVE_HPP
#define CPPA_IS_PRIMITIVE_HPP
#include "cppa/detail/type_to_ptype.hpp"
namespace cppa { namespace util {
/**
* @ingroup MetaProgramming
* @brief Chekcs wheter @p T is a primitive type.
*
* <code>is_primitive<T>::value == true</code> if and only if @c T
* is a signed / unsigned integer or one of the following types:
* - @c float
* - @c double
* - @c long @c double
* - @c std::string
* - @c std::u16string
* - @c std::u32string
*/
template<typename T>
struct is_primitive {
static constexpr bool value = detail::type_to_ptype<T>::ptype != pt_null;
};
} } // namespace cppa::util
#endif // CPPA_IS_PRIMITIVE_HPP
......@@ -34,7 +34,7 @@
#include <functional>
#include "cppa/guard_expr.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/rebindable_reference.hpp"
namespace cppa { namespace util {
......@@ -69,7 +69,7 @@ struct purge_refs_impl<std::reference_wrapper<const T> > {
*/
template<typename T>
struct purge_refs {
typedef typename purge_refs_impl<typename util::rm_ref<T>::type>::type type;
typedef typename purge_refs_impl<typename util::rm_const_and_ref<T>::type>::type type;
};
} } // namespace cppa::util
......
......@@ -32,13 +32,14 @@
#define CPPA_REBINDABLE_REFERENCE_HPP
#include "cppa/config.hpp"
#include "cppa/util/get_result_type.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa { namespace util {
template<typename T>
struct call_helper {
typedef typename get_result_type<T>::type result_type;
typedef typename map_to_result_type<T>::type result_type;
template<typename... Ts>
result_type operator()(T& f, const Ts&... args) const {
return f(std::forward<Ts>(args)...);
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_REPLACE_TYPE_HPP
#define CPPA_REPLACE_TYPE_HPP
#include <type_traits>
#include "cppa/util/disjunction.hpp"
namespace cppa { namespace detail {
template<bool DoReplace, typename T, typename ReplaceType>
struct replace_type {
typedef T type;
};
template<typename T, typename ReplaceType>
struct replace_type<true, T, ReplaceType> {
typedef ReplaceType type;
};
} } // namespace cppa::detail
namespace cppa { namespace util {
template<typename What, typename With, typename... IfStmt>
struct replace_type {
static constexpr bool do_replace = disjunction<IfStmt::value...>::value;
typedef typename detail::replace_type<do_replace, What, With>::type type;
};
} } // namespace cppa::util
#endif // CPPA_REPLACE_TYPE_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_RM_OPTION_HPP
#define CPPA_RM_OPTION_HPP
#include "cppa/option.hpp"
namespace cppa { namespace util {
template<typename T>
struct rm_option {
typedef T type;
};
template<typename T>
struct rm_option<option<T> > {
typedef T type;
};
} } // namespace cppa::util
#endif // CPPA_RM_OPTION_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#ifndef CPPA_RM_REF_HPP
#define CPPA_RM_REF_HPP
namespace cppa { namespace util {
/**
* @brief Like std::remove_reference but prohibits void and
* also removes const references.
*/
template<typename T>
struct rm_ref { typedef T type; };
template<typename T>
struct rm_ref<const T&> { typedef T type; };
template<typename T>
struct rm_ref<T&> { typedef T type; };
template<typename T>
struct rm_ref<const T> { typedef T type; };
template<>
struct rm_ref<void> { };
} } // namespace cppa::util
#endif // CPPA_RM_REF_HPP
......@@ -34,7 +34,6 @@
#include <typeinfo>
#include <type_traits>
#include "cppa/util/at.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_pair.hpp"
#include "cppa/util/void_type.hpp"
......@@ -49,10 +48,6 @@ const uniform_type_info* uniform_typeid(const std::type_info&);
namespace cppa { namespace util {
/**
* @defgroup MetaProgramming Metaprogramming utility.
*/
/**
* @addtogroup MetaProgramming
* @{
......@@ -93,7 +88,7 @@ struct tl_head<List<>> {
};
template<template<typename...> class List, typename T0, typename... Ts>
struct tl_head<List<T0,Ts...>> {
struct tl_head<List<T0, Ts...>> {
typedef T0 type;
};
......@@ -112,7 +107,7 @@ struct tl_tail<List<>> {
};
template<template<typename...> class List, typename T0, typename... Ts>
struct tl_tail<List<T0,Ts...>> {
struct tl_tail<List<T0, Ts...>> {
typedef List<Ts...> type;
};
......@@ -149,10 +144,10 @@ struct tl_back<List<T0>> {
};
template<template<typename...> class List, typename T0, typename T1, typename... Ts>
struct tl_back<List<T0,T1,Ts...>> {
struct tl_back<List<T0, T1, Ts...>> {
// remaining arguments are forwarded as type_list to prevent
// recursive instantiation of List class
typedef typename tl_back<type_list<T1,Ts...>>::type type;
typedef typename tl_back<type_list<T1, Ts...>>::type type;
};
......@@ -163,7 +158,7 @@ struct tl_back<List<T0,T1,Ts...>> {
*/
template<class List>
struct tl_empty {
static constexpr bool value = std::is_same<empty_type_list,List>::value;
static constexpr bool value = std::is_same<empty_type_list, List>::value;
};
// list slice(size_t, size_t)
......@@ -244,8 +239,8 @@ struct tl_slice {
* @brief Zips two lists of equal size.
*
* Creates a list formed from the two lists @p ListA and @p ListB,
* e.g., tl_zip<type_list<int,double>,type_list<float,string>>::type
* is type_list<type_pair<int,float>,type_pair<double,string>>.
* e.g., tl_zip<type_list<int, double>, type_list<float, string>>::type
* is type_list<type_pair<int, float>, type_pair<double, string>>.
*/
template<class ListA, class ListB,
template<typename, typename> class Fun = to_type_pair>
......@@ -344,11 +339,11 @@ struct tl_zip_with_index<empty_type_list> {
template<class List, typename T>
struct tl_index_of {
static constexpr size_t value = tl_index_of<typename tl_tail<List>::type,T>::value;
static constexpr size_t value = tl_index_of<typename tl_tail<List>::type, T>::value;
};
template<size_t N, typename T, typename... Ts>
struct tl_index_of<type_list<type_pair<std::integral_constant<size_t,N>,T>,Ts...>,T> {
struct tl_index_of<type_list<type_pair<std::integral_constant<size_t, N>, T>, Ts...>, T> {
static constexpr size_t value = N;
};
......@@ -399,25 +394,25 @@ struct tl_find_impl<type_list<T0, Ts...>, Predicate, Pos> {
};
/**
* @brief Finds the first element of type @p What beginning at
* @brief Finds the first element satisfying @p Predicate beginning at
* index @p Pos.
*/
template<class List, typename What, int Pos = 0>
struct tl_find {
static constexpr int value =
tl_find_impl<List,
tbind<std::is_same, What>::template type,
Pos
>::value;
template<class List, template<typename> class Predicate, int Pos = 0>
struct tl_find_if {
static constexpr int value = tl_find_impl<List, Predicate, Pos>::value;
};
/**
* @brief Finds the first element satisfying @p Predicate beginning at
* @brief Finds the first element of type @p What beginning at
* index @p Pos.
*/
template<class List, template<typename> class Predicate, int Pos = 0>
struct tl_find_if {
static constexpr int value = tl_find_impl<List, Predicate, Pos>::value;
template<class List, typename What, int Pos = 0>
struct tl_find {
static constexpr int value = tl_find_impl<
List,
tbind<std::is_same, What>::template type,
Pos
>::value;
};
// bool forall(predicate)
......@@ -923,7 +918,7 @@ struct tl_is_zipped {
template<class List, typename What = void_type>
struct tl_trim {
typedef typename std::conditional<
std::is_same<typename tl_back<List>::type,What>::value,
std::is_same<typename tl_back<List>::type, What>::value,
typename tl_trim<typename tl_pop_back<List>::type, What>::type,
List
>::type
......@@ -1009,7 +1004,7 @@ struct tl_apply<type_list<Ts...>, VarArgTemplate> {
namespace cppa {
template<size_t N, typename... Ts>
typename util::at<N, Ts...>::type get(const util::type_list<Ts...>&) {
typename util::tl_at<util::type_list<Ts...>, N>::type get(const util::type_list<Ts...>&) {
return {};
}
} // namespace cppa
......
This diff is collapsed.
......@@ -162,8 +162,8 @@ void multiplier() {
// to a tuple of vectors; note that this function returns
// an option (an empty results causes the actor to ignore
// the message)
[] (any_tuple msg) -> option<cow_tuple<fvec,fvec>> {
auto opt = tuple_cast<matrix_type,matrix_type>(msg);
[] (any_tuple msg) -> option<cow_tuple<fvec, fvec>> {
auto opt = tuple_cast<matrix_type, matrix_type>(msg);
if (opt) {
return {move(get_ref<0>(*opt).data()),
move(get_ref<1>(*opt).data())};
......
......@@ -101,7 +101,7 @@ void multiplier() {
// creates matrix_size * matrix_size global work items
// 4th arg: offsets for global dimensions (optional)
// 5th arg: local dimensions (optional)
auto worker = spawn_cl<fvec(fvec&,fvec&)>(kernel_source,
auto worker = spawn_cl<fvec(fvec&, fvec&)>(kernel_source,
kernel_name,
{matrix_size, matrix_size});
// send both matrices to the actor and wait for a result
......
......@@ -175,7 +175,7 @@ int main(int argc, char** argv) {
uint16_t port = 0;
options_description desc;
auto set_mode = [&](const string& arg) -> function<bool()> {
return [arg,&mode]() -> bool {
return [arg, &mode]() -> bool {
if (!mode.empty()) {
cerr << "mode already set to " << mode << endl;
return false;
......
......@@ -26,10 +26,10 @@ bool operator==(const foo& lhs, const foo& rhs) {
}
// a pair of two ints
typedef std::pair<int,int> foo_pair;
typedef std::pair<int, int> foo_pair;
// another pair of two ints
typedef std::pair<int,int> foo_pair2;
typedef std::pair<int, int> foo_pair2;
// a struct with member vector<vector<...>>
struct foo2 {
......@@ -49,10 +49,10 @@ void testee(size_t remaining) {
};
become (
// note: we sent a foo_pair2, but match on foo_pair
// that's safe because both are aliases for std::pair<int,int>
// that's safe because both are aliases for std::pair<int, int>
on<foo_pair>() >> [=](const foo_pair& val) {
cout << "foo_pair("
<< val.first << ","
<< val.first << ", "
<< val.second << ")"
<< endl;
set_next_behavior();
......@@ -64,10 +64,10 @@ void testee(size_t remaining) {
if (i != end) {
cout << *i;
while (++i != end) {
cout << "," << *i;
cout << ", " << *i;
}
}
cout << "}," << val.b << ")" << endl;
cout << "}, " << val.b << ")" << endl;
set_next_behavior();
}
);
......@@ -98,13 +98,13 @@ int main(int, char**) {
assert(vd == vd2);
// announce std::pair<int,int> to the type system;
// announce std::pair<int, int> to the type system;
// NOTE: foo_pair is NOT distinguishable from foo_pair2!
assert(announce<foo_pair>(&foo_pair::first, &foo_pair::second) == true);
// since foo_pair and foo_pair2 are not distinguishable since typedefs
// do not 'create' an own type, this announce fails, since
// std::pair<int,int> is already announced
// std::pair<int, int> is already announced
assert(announce<foo_pair2>(&foo_pair2::first, &foo_pair2::second) == false);
// libcppa returns the same uniform_type_info
......
......@@ -45,7 +45,7 @@ void testee() {
become (
on<foo>() >> [](const foo& val) {
aout << "foo("
<< val.a() << ","
<< val.a() << ", "
<< val.b() << ")"
<< endl;
self->quit();
......@@ -59,7 +59,7 @@ int main(int, char**) {
announce<foo>(make_pair(&foo::a, &foo::set_a),
make_pair(&foo::b, &foo::set_b));
auto t = spawn(testee);
send(t, foo{1,2});
send(t, foo{1, 2});
await_all_others_done();
shutdown();
return 0;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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