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,
......
......@@ -36,15 +36,11 @@
#include "cppa/tpartial_function.hpp"
#include "cppa/util/call.hpp"
#include "cppa/util/rm_ref.hpp"
#include "cppa/util/int_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/rm_option.hpp"
#include "cppa/util/purge_refs.hpp"
#include "cppa/util/disjunction.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/left_or_right.hpp"
#include "cppa/util/deduce_ref_type.hpp"
#include "cppa/util/get_result_type.hpp"
#include "cppa/util/rebindable_reference.hpp"
#include "cppa/detail/matches.hpp"
......@@ -82,7 +78,7 @@ struct invoke_policy_impl : invoke_policy_base<FilteredPattern> {
template<class Tuple>
static bool can_invoke(const std::type_info& type_token,
const Tuple& tup) {
typedef typename match_impl_from_type_list<Tuple,Pattern>::type mimpl;
typedef typename match_impl_from_type_list<Tuple, Pattern>::type mimpl;
return type_token == typeid(FilteredPattern) || mimpl::_(tup);
}
......@@ -98,7 +94,7 @@ struct invoke_policy_impl : invoke_policy_base<FilteredPattern> {
>::type
mimpl;
util::limited_vector<size_t,util::tl_size<FilteredPattern>::value> mv;
util::limited_vector<size_t, util::tl_size<FilteredPattern>::value> mv;
if (type_token == typeid(FilteredPattern) || mimpl::_(tup, mv)) {
for (size_t i = 0; i < util::tl_size<FilteredPattern>::value; ++i) {
result[i] = const_cast<void*>(tup.at(mv[i]));
......@@ -352,15 +348,15 @@ struct invoke_policy
: invoke_policy_impl<
get_wildcard_position<Pattern>(),
Pattern,
typename util::tl_filter_not_type<Pattern,anything>::type> {
typename util::tl_filter_not_type<Pattern, anything>::type> {
};
template<class Pattern, class Projection, class PartialFun>
struct projection_partial_function_pair : std::pair<Projection,PartialFun> {
struct projection_partial_function_pair : std::pair<Projection, PartialFun> {
template<typename... Ts>
projection_partial_function_pair(Ts&&... args)
: std::pair<Projection,PartialFun>(std::forward<Ts>(args)...) { }
: std::pair<Projection, PartialFun>(std::forward<Ts>(args)...) { }
typedef Pattern pattern_type;
};
......@@ -405,7 +401,7 @@ struct get_case_ {
typedef typename util::tl_zip<
typename util::tl_map<
padded_transformers,
util::get_result_type,
util::map_to_result_type,
util::rm_option,
std::add_lvalue_reference
>::type,
......@@ -444,28 +440,28 @@ struct get_case_ {
>::type
type2;
typedef projection_partial_function_pair<Pattern,type1,type2> type;
typedef projection_partial_function_pair<Pattern, type1, type2> type;
};
template<bool Complete, class Expr, class Guard, class Trans, class Pattern>
struct get_case {
typedef typename get_case_<Expr,Guard,Trans,Pattern>::type type;
typedef typename get_case_<Expr, Guard, Trans, Pattern>::type type;
};
template<class Expr, class Guard, class Trans, class Pattern>
struct get_case<false,Expr,Guard,Trans,Pattern> {
struct get_case<false, Expr, Guard, Trans, Pattern> {
typedef typename util::tl_pop_back<Pattern>::type lhs_pattern;
typedef typename util::tl_map<
typename util::get_arg_types<Expr>::types,
util::rm_ref
typename util::get_callable_trait<Expr>::arg_types,
util::rm_const_and_ref
>::type
rhs_pattern;
typedef typename get_case_<
Expr,
Guard,
Trans,
typename util::tl_concat<lhs_pattern,rhs_pattern>::type
typename util::tl_concat<lhs_pattern, rhs_pattern>::type
>::type
type;
};
......@@ -473,8 +469,8 @@ struct get_case<false,Expr,Guard,Trans,Pattern> {
template<typename Fun>
struct has_bool_result {
typedef typename Fun::result_type result_type;
static constexpr bool value = std::is_same<bool,result_type>::value;
typedef std::integral_constant<bool,value> token_type;
static constexpr bool value = std::is_same<bool, result_type>::value;
typedef std::integral_constant<bool, value> token_type;
};
template<typename T1, typename T2>
......@@ -510,7 +506,7 @@ bool unroll_expr(PPFPs& fs,
}
if ((bitmask & (0x01 << N)) == 0) return false;
auto& f = get<N>(fs);
typedef typename util::rm_ref<decltype(f)>::type Fun;
typedef typename util::rm_const_and_ref<decltype(f)>::type Fun;
typedef typename Fun::pattern_type pattern_type;
typedef detail::invoke_policy<pattern_type> policy;
typename policy::tuple_type targs;
......@@ -539,7 +535,7 @@ inline bool can_unroll_expr(PPFPs& fs, long_constant<N>, const std::type_info& a
return true;
}
auto& f = get<N>(fs);
typedef typename util::rm_ref<decltype(f)>::type Fun;
typedef typename util::rm_const_and_ref<decltype(f)>::type Fun;
typedef typename Fun::pattern_type pattern_type;
typedef detail::invoke_policy<pattern_type> policy;
return policy::can_invoke(arg_types, tup);
......@@ -553,7 +549,7 @@ inline std::uint64_t calc_bitmask(PPFPs&, minus1l, const std::type_info&, const
template<class PPFPs, long N, class Tuple>
inline std::uint64_t calc_bitmask(PPFPs& fs, long_constant<N>, const std::type_info& tinf, const Tuple& tup) {
auto& f = get<N>(fs);
typedef typename util::rm_ref<decltype(f)>::type Fun;
typedef typename util::rm_const_and_ref<decltype(f)>::type Fun;
typedef typename Fun::pattern_type pattern_type;
typedef detail::invoke_policy<pattern_type> policy;
std::uint64_t result = policy::can_invoke(tinf, tup) ? (0x01 << N) : 0x00;
......@@ -566,12 +562,12 @@ struct mexpr_fwd_ {
};
template<typename T>
struct mexpr_fwd_<false,const T&,T> {
struct mexpr_fwd_<false, const T&, T> {
typedef std::reference_wrapper<const T> type;
};
template<typename T>
struct mexpr_fwd_<true,T&,T> {
struct mexpr_fwd_<true, T&, T> {
typedef std::reference_wrapper<T> type;
};
......@@ -581,7 +577,7 @@ struct mexpr_fwd {
IsManipulator,
T,
typename detail::implicit_conversions<
typename util::rm_ref<T>::type
typename util::rm_const_and_ref<T>::type
>::type
>::type
type;
......@@ -638,7 +634,7 @@ class match_expr {
typedef util::type_list<Cs...> cases_list;
static constexpr bool has_manipulator = util::tl_exists<cases_list,is_manipulator_case>::value;
static constexpr bool has_manipulator = util::tl_exists<cases_list, is_manipulator_case>::value;
typedef detail::long_constant<sizeof...(Cs)-1l> idx_token_type;
......@@ -736,7 +732,7 @@ class match_expr {
}
template<class... Ds>
match_expr<Cs...,Ds...> or_else(const match_expr<Ds...>& other) const {
match_expr<Cs..., Ds...> or_else(const match_expr<Ds...>& other) const {
detail::tdata<util::rebindable_reference<const Cs>...,
util::rebindable_reference<const Ds>... > all_cases;
rebind_tdata(all_cases, m_cases, other.cases());
......@@ -762,7 +758,7 @@ class match_expr {
}
typedef typename detail::behavior_impl::pointer pointer;
pointer copy(const generic_timeout_definition& tdef) const {
return new_default_behavior_impl(pfun, tdef.timeout, tdef.handler);
return new_default_behavior(pfun, tdef.timeout, tdef.handler);
}
};
......@@ -779,9 +775,9 @@ class match_expr {
static constexpr size_t cache_size = 10;
typedef std::pair<const std::type_info*,std::uint64_t> cache_element;
typedef std::pair<const std::type_info*, std::uint64_t> cache_element;
util::limited_vector<cache_element,cache_size> m_cache;
util::limited_vector<cache_element, cache_size> m_cache;
// ring buffer like access to m_cache
size_t m_cache_begin;
......@@ -831,7 +827,7 @@ class match_expr {
template<class Tuple>
bool invoke_impl(Tuple& tup) {
std::integral_constant<bool,has_manipulator> mutator_token;
std::integral_constant<bool, has_manipulator> mutator_token;
// returns either a reference or a new object
typedef decltype(detail::detach_if_needed(tup, mutator_token)) detached;
detached tref = detail::detach_if_needed(tup, mutator_token);
......@@ -863,7 +859,7 @@ struct match_expr_from_type_list<util::type_list<Ts...> > {
};
template<typename... Lhs, typename... Rhs>
inline match_expr<Lhs...,Rhs...> operator,(const match_expr<Lhs...>& lhs,
inline match_expr<Lhs..., Rhs...> operator,(const match_expr<Lhs...>& lhs,
const match_expr<Rhs...>& rhs) {
return lhs.or_else(rhs);
}
......@@ -917,7 +913,7 @@ typedef std::false_type without_timeout;
template<class Data, class Token, typename F>
behavior_impl* concat_rec(const Data& data, Token, const timeout_definition<F>& arg) {
typedef typename match_expr_from_type_list<Token>::type combined_type;
return new default_behavior_impl<combined_type,F>{data, arg};
return new default_behavior_impl<combined_type, F>{data, arg};
}
// recursive concatenation function
......@@ -942,7 +938,7 @@ behavior_impl* concat_rec(const Data& data, Token, const T& arg, const Ts&... ar
template<typename F>
behavior_impl* concat_expr(with_timeout, const timeout_definition<F>& arg) {
typedef default_behavior_impl<dummy_match_expr,F> impl_type;
typedef default_behavior_impl<dummy_match_expr, F> impl_type;
return new impl_type(dummy_match_expr{}, arg);
}
......@@ -980,15 +976,15 @@ behavior_impl* concat_expr(without_timeout, const T& arg, const Ts&... args) {
>::type
>::type
combined_type;
auto lvoid = []() { };
typedef default_behavior_impl<combined_type,decltype(lvoid)> impl_type;
auto lvoid = [] { };
typedef default_behavior_impl<combined_type, decltype(lvoid)> impl_type;
rebind_tdata(all_cases, arg.cases(), args.cases()...);
return new impl_type(all_cases, util::duration{}, lvoid);
}
template<typename T, typename... Ts>
behavior_impl_ptr match_expr_concat(const T& arg, const Ts&... args) {
std::integral_constant<bool,util::disjunction<T::may_have_timeout,Ts::may_have_timeout...>::value> token;
std::integral_constant<bool, util::disjunction<T::may_have_timeout, Ts::may_have_timeout...>::value> token;
// use static call dispatch to select correct function
return concat_expr(token, arg, args...);
}
......
......@@ -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
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \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_TYPE_TRAITS_HPP
#define CPPA_UTIL_TYPE_TRAITS_HPP
#include <string>
#include <functional>
#include <type_traits>
#include "cppa/cppa_fwd.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/type_traits.hpp"
namespace cppa { namespace util {
/**
* @addtogroup MetaProgramming
* @{
*/
/**
* @brief Equal to std::remove_const<std::remove_reference<T>::type>.
*/
template<typename T>
struct rm_const_and_ref { typedef T type; };
template<typename T> struct rm_const_and_ref<const T&> { typedef T type; };
template<typename T> struct rm_const_and_ref<const T> { typedef T type; };
template<typename T> struct rm_const_and_ref<T&> { typedef T type; };
template<> struct rm_const_and_ref<void> { };
/**
* @brief Joins all bool constants using operator &&.
*/
template<bool... BoolConstants>
struct conjunction;
template<>
struct conjunction<> { static constexpr bool value = false; };
template<bool V0>
struct conjunction<V0> {
static constexpr bool value = V0;
};
template<bool V0, bool V1, bool... Vs>
struct conjunction<V0, V1, Vs...> {
static constexpr bool value = V0 && conjunction<V1, Vs...>::value;
};
/**
* @brief Joins all bool constants using operator ||.
*/
template<bool... BoolConstants>
struct disjunction;
template<bool V0, bool... Vs>
struct disjunction<V0, Vs...> {
static constexpr bool value = V0 || disjunction<Vs...>::value;
};
template<>
struct disjunction<> { static constexpr bool value = false; };
/**
* @brief Equal to std::is_same<T, anything>.
*/
template<typename T>
struct is_anything : std::is_same<T, anything> { };
/**
* @brief Checks whether @p T is an array of type @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;
};
/**
* @brief Deduces the reference type of T0 and applies it to T1.
*/
template<typename T0, typename T1>
struct deduce_ref_type {
typedef typename util::rm_const_and_ref<T1>::type type;
};
template<typename T0, typename T1>
struct deduce_ref_type<T0&, T1> {
typedef typename util::rm_const_and_ref<T1>::type& type;
};
template<typename T0, typename T1>
struct deduce_ref_type<const T0&, T1> {
typedef const typename util::rm_const_and_ref<T1>::type& type;
};
/**
* @brief Checks wheter @p X is in the template parameter pack Ts.
*/
template<typename X, typename... Ts>
struct is_one_of;
template<typename X>
struct is_one_of<X> : std::false_type { };
template<typename X, typename... Ts>
struct is_one_of<X, X, Ts...> : std::true_type { };
template<typename X, typename T0, typename... Ts>
struct is_one_of<X, T0, Ts...> : is_one_of<X, Ts...> { };
/**
* @brief Checks wheter @p T is considered a builtin type.
*
* Builtin types are: (1) all arithmetic types, (2) string types from the STL,
* and (3) libcppa types such as @p actor_ptr.
*/
template<typename T>
struct is_builtin {
// all arithmetic types are considered builtin
static constexpr bool value = std::is_arithmetic<T>::value
|| is_one_of<
T,
anything,
std::string,
std::u16string,
std::u32string,
atom_value,
any_tuple,
message_header,
actor_ptr,
group_ptr,
channel_ptr,
process_information_ptr
>::value;
};
/**
* @brief Chekcs wheter @p T is primitive, i.e., either an arithmetic
* type or convertible to one of STL's string types.
*/
template<typename T>
struct is_primitive {
static constexpr bool value = std::is_arithmetic<T>::value
|| std::is_convertible<T, std::string>::value
|| std::is_convertible<T, std::u16string>::value
|| std::is_convertible<T, std::u32string>::value;
};
/**
* @brief Chekcs wheter @p T1 is comparable with @p T2.
*/
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;
};
/**
* @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_const_and_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;
};
/**
* @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;
};
/**
* @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;
};
/**
* @brief Checks wheter @p T is a non-const reference.
*/
template<typename T>
struct is_mutable_ref {
static constexpr bool value = std::is_reference<T>::value
&& not std::is_const<T>::value;
};
/**
* @brief Returns either @p T or @p T::type if @p T is an option.
*/
template<typename T>
struct rm_option {
typedef T type;
};
template<typename T>
struct rm_option<option<T> > {
typedef T type;
};
/**
* @brief Defines @p result_type, @p arg_types, and @p fun_type. Functor is
* (a) a member function pointer, (b) a function,
* (c) a function pointer, (d) an std::function.
*
* @p result_type is the result type found in the signature.
* @p arg_types are the argument types as {@link type_list}.
* @p fun_type is an std::function with an equivalent signature.
*/
template<typename Functor>
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;
};
/**
* @brief Gets a callable trait for @p T, where @p T is a functor type,
* i.e., a function, member function, or a class providing
* the call operator.
*/
template<typename T>
struct get_callable_trait {
// type without cv qualifiers
typedef typename rm_const_and_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;
};
/**
* @brief Checks wheter @p T is a function or member function.
*/
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_const_and_ref<T>::type*>(nullptr)))
result_type;
public:
static constexpr bool value = std::is_same<bool, result_type>::value;
};
/**
* @brief Checks wheter each @p T in @p Ts is a function or member function.
*/
template<typename... Ts>
struct all_callable {
static constexpr bool value = conjunction<is_callable<Ts>::value...>::value;
};
/**
* @brief Checks wheter @p F takes mutable references.
*
* A manipulator is a functor that manipulates its arguments via
* mutable references.
*/
template<typename F>
struct is_manipulator {
static constexpr bool value =
tl_exists<typename get_callable_trait<F>::arg_types, is_mutable_ref>::value;
};
template<bool IsCallable, typename C>
struct map_to_result_type_impl {
typedef typename get_callable_trait<C>::type trait_type;
typedef typename trait_type::result_type type;
};
template<typename C>
struct map_to_result_type_impl<false, C> {
typedef void_type type;
};
/**
* @brief Maps @p T to its result type if it's callable,
* {@link void_type} otherwise.
*/
template<typename T>
struct map_to_result_type {
typedef typename map_to_result_type_impl<is_callable<T>::value, T>::type type;
};
template<bool DoReplace, typename T1, typename T2>
struct replace_type_impl {
typedef T1 type;
};
template<typename T1, typename T2>
struct replace_type_impl<true, T1, T2> {
typedef T2 type;
};
/**
* @brief Replaces @p What with @p With if any IfStmt::value evaluates to true.
*/
template<typename What, typename With, typename... IfStmt>
struct replace_type {
static constexpr bool do_replace = disjunction<IfStmt::value...>::value;
typedef typename replace_type_impl<do_replace, What, With>::type type;
};
/**
* @brief Gets the Nth element of the template parameter pack @p Ts.
*/
template<size_t N, typename... Ts>
struct type_at;
template<size_t N, typename T0, typename... Ts>
struct type_at<N, T0, Ts...> {
typedef typename type_at<N-1, Ts...>::type type;
};
template<typename T0, typename... Ts>
struct type_at<0, T0, Ts...> {
typedef T0 type;
};
/**
* @}
*/
} } // namespace cppa::util
#endif // CPPA_UTIL_TYPE_TRAITS_HPP
......@@ -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;
......
......@@ -50,7 +50,7 @@ void testee() {
become (
on<foo>() >> [](const foo& val) {
aout << "foo("
<< val.a() << ","
<< val.a() << ", "
<< val.b() << ")"
<< endl;
self->quit();
......@@ -78,7 +78,7 @@ int main(int, char**) {
static_cast<foo_setter>(&foo::b)));
// spawn a new testee and send it a foo
send(spawn(testee), foo{1,2});
send(spawn(testee), foo{1, 2});
await_all_others_done();
shutdown();
return 0;
......
......@@ -87,8 +87,8 @@ void testee(size_t remaining) {
become (
on<bar>() >> [=](const bar& val) {
aout << "bar(foo("
<< val.f.a() << ","
<< val.f.b() << "),"
<< val.f.a() << ", "
<< val.f.b() << "), "
<< val.i << ")"
<< endl;
set_next_behavior();
......@@ -127,8 +127,8 @@ int main(int, char**) {
// spawn a testee that receives two messages
auto t = spawn(testee, 2);
send(t, bar{foo{1,2},3});
send(t, baz{foo{1,2},bar{foo{3,4},5}});
send(t, bar{foo{1, 2}, 3});
send(t, baz{foo{1, 2}, bar{foo{3, 4}, 5}});
await_all_others_done();
shutdown();
return 0;
......
......@@ -163,7 +163,7 @@ void testee(size_t remaining) {
aout << "received " << trees.size() << " trees" << endl;
// prints:
// @<> ( {
// std::vector<tree,std::allocator<tree>> ( {
// std::vector<tree, std::allocator<tree>> ( {
// tree ( 0, { 10, { 11, { }, 12, { }, 13, { } }, 20, { 21, { }, 22, { } } } ),
// tree ( 0, { 10, { 11, { }, 12, { }, 13, { } }, 20, { 21, { }, 22, { } } } )
// )
......
......@@ -37,7 +37,7 @@ using namespace std;
namespace cppa { namespace detail {
struct behavior_stack_mover : iterator<output_iterator_tag,void,void,void,void>{
struct behavior_stack_mover : iterator<output_iterator_tag, void, void, void, void>{
public:
......
......@@ -106,7 +106,7 @@ void default_actor_proxy::forward_msg(const message_header& hdr, any_tuple msg)
switch (m_pending_requests.enqueue(new_req_info(hdr.sender, hdr.id))) {
case intrusive::queue_closed: {
auto rsn = exit_reason();
m_proto->run_later([rsn,hdr] {
m_proto->run_later([rsn, hdr] {
CPPA_LOGC_TRACE("cppa::network::default_actor_proxy",
"forward_msg$bouncer",
"bounce message for reason " << rsn);
......@@ -130,7 +130,7 @@ void default_actor_proxy::forward_msg(const message_header& hdr, any_tuple msg)
void default_actor_proxy::enqueue(const message_header& hdr, any_tuple msg) {
CPPA_LOG_TRACE(CPPA_TARG(hdr, to_string) << ", " << CPPA_TARG(msg, to_string));
auto& arr = detail::static_types_array<atom_value,uint32_t>::arr;
auto& arr = detail::static_types_array<atom_value, uint32_t>::arr;
if ( msg.size() == 2
&& msg.type_at(0) == arr[0]
&& msg.get_as<atom_value>(0) == atom("KILL_PROXY")
......
......@@ -101,7 +101,7 @@ struct group_nameserver : event_based_actor {
};
void publish_local_groups_at(std::uint16_t port, const char* addr) {
auto gn = spawn<group_nameserver,hidden>();
auto gn = spawn<group_nameserver, hidden>();
try {
publish(gn, port, addr);
}
......
......@@ -83,7 +83,7 @@ class local_group : public group {
m_broker->enqueue(hdr, move(msg));
}
pair<bool,size_t> add_subscriber(const channel_ptr& who) {
pair<bool, size_t> add_subscriber(const channel_ptr& who) {
CPPA_LOG_TRACE(CPPA_TARG(who, to_string));
exclusive_guard guard(m_mtx);
if (m_subscribers.insert(who).second) {
......@@ -92,7 +92,7 @@ class local_group : public group {
return {false, m_subscribers.size()};
}
pair<bool,size_t> erase_subscriber(const channel_ptr& who) {
pair<bool, size_t> erase_subscriber(const channel_ptr& who) {
CPPA_LOG_TRACE(CPPA_TARG(who, to_string));
exclusive_guard guard(m_mtx);
auto success = m_subscribers.erase(who) > 0;
......@@ -212,7 +212,7 @@ class local_group_proxy : public local_group {
CPPA_REQUIRE(remote_broker != nullptr);
CPPA_REQUIRE(remote_broker->is_proxy());
m_broker = move(remote_broker);
m_proxy_broker = spawn<proxy_broker,hidden>(this);
m_proxy_broker = spawn<proxy_broker, hidden>(this);
}
group::subscription subscribe(const channel_ptr& who) {
......@@ -342,9 +342,9 @@ class local_group_module : public group::module {
process_information_ptr m_process;
const uniform_type_info* m_actor_utype;
util::shared_spinlock m_instances_mtx;
map<string,local_group_ptr> m_instances;
map<string, local_group_ptr> m_instances;
util::shared_spinlock m_proxies_mtx;
map<actor_ptr,local_group_ptr> m_proxies;
map<actor_ptr, local_group_ptr> m_proxies;
};
......@@ -456,7 +456,7 @@ class remote_group_module : public group::module {
CPPA_LOGC_TRACE(detail::demangle(typeid(*_this)),
"remote_group_module$worker",
"");
typedef map<string,pair<actor_ptr,vector<pair<string,remote_group_ptr>>>>
typedef map<string, pair<actor_ptr, vector<pair<string, remote_group_ptr>>>>
peer_map;
peer_map peers;
receive_loop (
......
......@@ -47,7 +47,7 @@ pthread_once_t s_key_once = PTHREAD_ONCE_INIT;
memory_cache::~memory_cache() { }
typedef map<const type_info*,unique_ptr<memory_cache> > cache_map;
typedef map<const type_info*, unique_ptr<memory_cache> > cache_map;
void cache_map_destructor(void* ptr) {
if (ptr) delete reinterpret_cast<cache_map*>(ptr);
......@@ -84,7 +84,7 @@ void memory::add_cache_map_entry(const type_info* tinf, memory_cache* instance)
instance_wrapper::~instance_wrapper() { }
//pair<instance_wrapper*,void*> memory::allocate(const type_info* type) {
//pair<instance_wrapper*, void*> memory::allocate(const type_info* type) {
// return get_cache_map_entry(type)->allocate();
//}
......
......@@ -81,7 +81,7 @@ namespace cppa { namespace network {
#ifdef CPPA_POLL_IMPL
typedef pair<vector<pollfd>::iterator,vector<fd_meta_info>::iterator>
typedef pair<vector<pollfd>::iterator, vector<fd_meta_info>::iterator>
pfd_iterator;
#ifndef POLLRDHUP
......@@ -117,7 +117,7 @@ struct pfd_access {
};
typedef event_iterator_impl<pfd_iterator,pfd_access> event_iterator;
typedef event_iterator_impl<pfd_iterator, pfd_access> event_iterator;
struct pollfd_meta_info_less {
inline bool operator()(const pollfd& lhs, native_socket_type rhs) const {
......@@ -142,7 +142,7 @@ class middleman_event_handler : public middleman_event_handler_base<middleman_ev
size_t num_sockets() const { return m_pollset.size(); }
pair<event_iterator,event_iterator> poll() {
pair<event_iterator, event_iterator> poll() {
CPPA_REQUIRE(m_pollset.empty() == false);
CPPA_REQUIRE(m_pollset.size() == m_meta.size());
for (;;) {
......@@ -258,7 +258,7 @@ struct epoll_iterator_access {
};
typedef event_iterator_impl<vector<epoll_event>::iterator,epoll_iterator_access>
typedef event_iterator_impl<vector<epoll_event>::iterator, epoll_iterator_access>
event_iterator;
class middleman_event_handler : public middleman_event_handler_base<middleman_event_handler> {
......@@ -279,7 +279,7 @@ class middleman_event_handler : public middleman_event_handler_base<middleman_ev
size_t num_sockets() const { return m_meta.size(); }
pair<event_iterator,event_iterator> poll() {
pair<event_iterator, event_iterator> poll() {
CPPA_REQUIRE(m_meta.empty() == false);
for (;;) {
CPPA_LOGMF(CPPA_DEBUG, self, "epoll_wait on " << num_sockets() << " sockets");
......@@ -470,7 +470,7 @@ class middleman_impl : public abstract_middleman {
middleman_event_handler m_handler;
util::shared_spinlock m_protocols_lock;
map<atom_value,protocol_ptr> m_protocols;
map<atom_value, protocol_ptr> m_protocols;
};
......
......@@ -110,7 +110,7 @@ function<void()> print_desc(options_description* desc, ostream& out) {
tmp << "=<arg1>";
}
for (size_t num = 2; num <= opt.second.num_args; ++num) {
tmp << ",<arg" << num << ">";
tmp << ", <arg" << num << ">";
}
out << tmp.str() << opt.second.help_text << "\n";
}
......
......@@ -43,7 +43,7 @@ void scheduled_actor_dummy::do_become(behavior&&, bool) { }
void scheduled_actor_dummy::become_waiting_for(behavior, message_id) { }
bool scheduled_actor_dummy::has_behavior() { return false; }
resume_result scheduled_actor_dummy::resume(util::fiber*,actor_ptr&) {
resume_result scheduled_actor_dummy::resume(util::fiber*, actor_ptr&) {
return resume_result::actor_blocked;
}
......
......@@ -157,9 +157,9 @@ void scheduler_helper::timer_loop(scheduler_helper::ptr_type m_self) {
// setup & local variables
self.set(m_self.get());
bool done = false;
std::unique_ptr<mailbox_element,detail::disposer> msg_ptr;
std::unique_ptr<mailbox_element, detail::disposer> msg_ptr;
auto tout = hrc::now();
std::multimap<decltype(tout),delayed_msg> messages;
std::multimap<decltype(tout), delayed_msg> messages;
// message handling rules
auto mfun = (
on(atom("SEND"), arg_match) >> [&](const util::duration& d,
......@@ -210,7 +210,7 @@ void scheduler_helper::timer_loop(scheduler_helper::ptr_type m_self) {
void scheduler_helper::printer_loop(ptr_type m_self) {
self.set(m_self.get());
std::map<actor_ptr,std::string> out;
std::map<actor_ptr, std::string> out;
auto flush_output = [&out](const actor_ptr& s) {
auto i = out.find(s);
if (i != out.end()) {
......
......@@ -116,15 +116,15 @@ class parse_tree {
full_name += "<";
for (auto& tparam : m_template_parameters) {
// decorate each single template parameter
if (full_name.back() != '<') full_name += ",";
if (full_name.back() != '<') full_name += ',';
full_name += tparam.compile();
}
full_name += ">";
// decorate full name
result += map2decorated(full_name.c_str());
}
if (m_pointer) result += "*";
if (m_lvalue_ref) result += "&";
if (m_pointer) result += '*';
if (m_lvalue_ref) result += '&';
if (m_rvalue_ref) result += "&&";
return result;
}
......
......@@ -534,7 +534,7 @@ void push_native_type(abstract_int_tinfo* m [][2]) {
template<typename T0, typename T1, typename... Ts>
void push_native_type(abstract_int_tinfo* m [][2]) {
push_native_type<T0>(m);
push_native_type<T1,Ts...>(m);
push_native_type<T1, Ts...>(m);
}
class utim_impl : public uniform_type_info_map {
......@@ -667,7 +667,7 @@ class utim_impl : public uniform_type_info_map {
private:
typedef std::map<std::string,std::string> strmap;
typedef std::map<std::string, std::string> strmap;
uti_impl<process_information_ptr> m_type_proc;
uti_impl<channel_ptr> m_type_channel;
......@@ -696,7 +696,7 @@ class utim_impl : public uniform_type_info_map {
int_tinfo<std::uint64_t> m_type_u64;
// both containers are sorted by uniform name
std::array<pointer,25> m_builtin_types;
std::array<pointer, 25> m_builtin_types;
std::vector<uniform_type_info*> m_user_types;
template<typename Container>
......
......@@ -44,7 +44,7 @@ struct both_integral {
};
template<bool V, typename T1, typename T2>
struct enable_integral : std::enable_if< both_integral<T1,T2>::value == V
struct enable_integral : std::enable_if< both_integral<T1, T2>::value == V
&& not std::is_pointer<T1>::value
&& not std::is_pointer<T2>::value> { };
......@@ -91,7 +91,7 @@ inline void cppa_check_value(const V1& v1,
const char* fname,
int line,
bool expected = true,
typename enable_integral<false,V1,V2>::type* = 0) {
typename enable_integral<false, V1, V2>::type* = 0) {
if ((v1 == v2) == expected) cppa_passed(fname, line);
else cppa_failed(v1, v2, fname, line);
}
......@@ -102,7 +102,7 @@ inline void cppa_check_value(V1 v1,
const char* fname,
int line,
bool expected = true,
typename enable_integral<true,V1,V2>::type* = 0) {
typename enable_integral<true, V1, V2>::type* = 0) {
if ((v1 == static_cast<V1>(v2)) == expected) cppa_passed(fname, line);
else cppa_failed(v1, v2, fname, line);
}
......
......@@ -14,12 +14,12 @@ using cppa::util::limited_vector;
int main() {
CPPA_TEST(test_limited_vector);
int arr1[] {1, 2, 3, 4};
limited_vector<int,4> vec1 {1, 2, 3, 4};
limited_vector<int,5> vec2 {4, 3, 2, 1};
limited_vector<int,4> vec3;
limited_vector<int, 4> vec1 {1, 2, 3, 4};
limited_vector<int, 5> vec2 {4, 3, 2, 1};
limited_vector<int, 4> vec3;
for (int i = 1; i <= 4; ++i) vec3.push_back(i);
limited_vector<int,4> vec4 {1, 2};
limited_vector<int,2> vec5 {3, 4};
limited_vector<int, 4> vec4 {1, 2};
limited_vector<int, 2> vec5 {3, 4};
vec4.insert(vec4.end(), vec5.begin(), vec5.end());
auto vec6 = vec4;
CPPA_CHECK_EQUAL(vec1.size(), 4);
......@@ -39,13 +39,13 @@ int main() {
CPPA_CHECK(std::equal(vec4.begin(), vec4.end(), arr1));
CPPA_CHECK(std::equal(vec6.begin(), vec6.end(), arr1));
CPPA_CHECK(std::equal(vec6.begin(), vec6.end(), vec2.rbegin()));
limited_vector<int,10> vec7 {5, 9};
limited_vector<int,10> vec8 {1, 2, 3, 4};
limited_vector<int,10> vec9 {6, 7, 8};
limited_vector<int, 10> vec7 {5, 9};
limited_vector<int, 10> vec8 {1, 2, 3, 4};
limited_vector<int, 10> vec9 {6, 7, 8};
vec7.insert(vec7.begin() + 1, vec9.begin(), vec9.end());
vec7.insert(vec7.begin(), vec8.begin(), vec8.end());
CPPA_CHECK_EQUAL(vec7.full(), false);
limited_vector<int,1> vec10 {10};
limited_vector<int, 1> vec10 {10};
vec7.insert(vec7.end(), vec10.begin(), vec10.end());
CPPA_CHECK_EQUAL(vec7.full(), true);
CPPA_CHECK((std::is_sorted(vec7.begin(), vec7.end())));
......
......@@ -104,7 +104,7 @@ int main() {
CPPA_CHECK_EQUAL((ge_invoke(expr14, 2, 3)), 5);
auto expr15 = _x1 + _x2 + _x3;
static_assert(std::is_same<decltype(ge_invoke(expr15,1,2,3)), int>::value,
static_assert(std::is_same<decltype(ge_invoke(expr15, 1, 2, 3)), int>::value,
"wrong return type");
CPPA_CHECK_EQUAL((ge_invoke(expr15, 7, 10, 25)), 42);
......@@ -339,17 +339,17 @@ int main() {
}
partial_function pf0 = (
on<int,int>() >> [&] { last_invoked_fun = "<int,int>@1"; },
on<int, int>() >> [&] { last_invoked_fun = "<int, int>@1"; },
on<float>() >> [&] { last_invoked_fun = "<float>@2"; }
);
auto pf1 = pf0.or_else(
on<int,int>() >> [&] { last_invoked_fun = "<int,int>@3"; },
on<int, int>() >> [&] { last_invoked_fun = "<int, int>@3"; },
on<string>() >> [&] { last_invoked_fun = "<string>@4"; }
);
check(pf0, make_any_tuple(1, 2), "<int,int>@1");
check(pf1, make_any_tuple(1, 2), "<int,int>@1");
check(pf0, make_any_tuple(1, 2), "<int, int>@1");
check(pf1, make_any_tuple(1, 2), "<int, int>@1");
check(pf0, make_any_tuple("hi"), "");
check(pf1, make_any_tuple("hi"), "<string>@4");
......
......@@ -7,10 +7,8 @@
#include "cppa/uniform_type_info.hpp"
#include "cppa/util/at.hpp"
#include "cppa/util/int_list.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/element_at.hpp"
#include "cppa/detail/demangle.hpp"
......@@ -27,32 +25,32 @@ int main() {
CPPA_PRINT("test type_list");
typedef type_list<int,float,std::string> l1;
typedef type_list<int, float, std::string> l1;
typedef typename tl_reverse<l1>::type r1;
CPPA_CHECK((is_same<int,element_at<0,l1>::type>::value));
CPPA_CHECK((is_same<float,element_at<1,l1>::type>::value));
CPPA_CHECK((is_same<std::string,element_at<2,l1>::type>::value));
CPPA_CHECK((is_same<int, tl_at<l1, 0>::type>::value));
CPPA_CHECK((is_same<float, tl_at<l1, 1>::type>::value));
CPPA_CHECK((is_same<std::string, tl_at<l1, 2>::type>::value));
CPPA_CHECK_EQUAL(3 ,tl_size<l1>::value);
CPPA_CHECK_EQUAL(3 , tl_size<l1>::value);
CPPA_CHECK_EQUAL(tl_size<r1>::value, tl_size<l1>::value);
CPPA_CHECK((is_same<element_at<0,l1>::type,element_at<2,r1>::type>::value));
CPPA_CHECK((is_same<element_at<1,l1>::type,element_at<1,r1>::type>::value));
CPPA_CHECK((is_same<element_at<2,l1>::type,element_at<0,r1>::type>::value));
CPPA_CHECK((is_same<tl_at<l1, 0>::type, tl_at<r1, 2>::type>::value));
CPPA_CHECK((is_same<tl_at<l1, 1>::type, tl_at<r1, 1>::type>::value));
CPPA_CHECK((is_same<tl_at<l1, 2>::type, tl_at<r1, 0>::type>::value));
typedef tl_concat<type_list<int>,l1>::type l2;
typedef tl_concat<type_list<int>, l1>::type l2;
CPPA_CHECK((is_same<int,tl_head<l2>::type>::value));
CPPA_CHECK((is_same<l1,tl_tail<l2>::type>::value));
CPPA_CHECK((is_same<int, tl_head<l2>::type>::value));
CPPA_CHECK((is_same<l1, tl_tail<l2>::type>::value));
CPPA_PRINT("test int_list");
typedef int_list<0,1,2,3,4,5> il0;
typedef int_list<4,5> il1;
typedef typename il_right<il0,2>::type il2;
CPPA_CHECK_VERBOSE((is_same<il2,il1>::value),
"il_right<il0,2> returned " <<detail::demangle<il2>()
typedef int_list<0, 1, 2, 3, 4, 5> il0;
typedef int_list<4, 5> il1;
typedef typename il_right<il0, 2>::type il2;
CPPA_CHECK_VERBOSE((is_same<il2, il1>::value),
"il_right<il0, 2> returned " <<detail::demangle<il2>()
<< "expected: " << detail::demangle<il1>());
return CPPA_TEST_RESULT();
......
......@@ -109,13 +109,13 @@ int main() {
announce<matrix_type>();
const ivec expected1{ 56, 62, 68, 74
,152,174,196,218
,248,286,324,362
,344,398,452,506};
, 152, 174, 196, 218
, 248, 286, 324, 362
, 344, 398, 452, 506};
auto worker1 = spawn_cl<ivec(ivec&)>(program::create(kernel_source),
kernel_name,
{matrix_size,matrix_size});
{matrix_size, matrix_size});
ivec m1(matrix_size * matrix_size);
iota(m1.begin(), m1.end(), 0);
send(worker1, move(m1));
......@@ -127,7 +127,7 @@ int main() {
auto worker2 = spawn_cl<ivec(ivec&)>(kernel_source,
kernel_name,
{matrix_size,matrix_size});
{matrix_size, matrix_size});
ivec m2(matrix_size * matrix_size);
iota(m2.begin(), m2.end(), 0);
send(worker2, move(m2));
......
......@@ -357,7 +357,7 @@ void run_client_part(const vector<string_pair>& args) {
auto server2 = remote_actor("localhost", port);
CPPA_CHECK(serv == server2);
}
auto c = spawn<client,monitored>(serv);
auto c = spawn<client, monitored>(serv);
receive (
on(atom("DOWN"), arg_match) >> [=](uint32_t rsn) {
CPPA_CHECK_EQUAL(self->last_sender(), c);
......@@ -386,7 +386,7 @@ int main(int argc, char** argv) {
}
}
CPPA_TEST(test_remote_actor);
auto serv = spawn<server,monitored>();
auto serv = spawn<server, monitored>();
uint16_t port = 4242;
bool success = false;
do {
......
......@@ -44,8 +44,7 @@
#include "cppa/util/get_mac_addresses.hpp"
#include "cppa/util/pt_token.hpp"
#include "cppa/util/is_iterable.hpp"
#include "cppa/util/is_primitive.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/util/abstract_uniform_type_info.hpp"
#include "cppa/network/default_actor_addressing.hpp"
......@@ -147,7 +146,7 @@ struct raw_struct_type_info : util::abstract_uniform_type_info<raw_struct> {
int main() {
CPPA_TEST(test_serialization);
typedef std::integral_constant<int,detail::impl_id<strmap>()> token;
typedef std::integral_constant<int, detail::impl_id<strmap>()> token;
CPPA_CHECK_EQUAL(util::is_iterable<strmap>::value, true);
CPPA_CHECK_EQUAL(detail::is_stl_compliant_list<vector<int>>::value, true);
CPPA_CHECK_EQUAL(detail::is_stl_compliant_list<strmap>::value, false);
......@@ -277,7 +276,7 @@ int main() {
// string is primitive and thus not identified by is_iterable
CPPA_CHECK((is_iterable<string>::value) == false);
CPPA_CHECK((is_iterable<list<int>>::value) == true);
CPPA_CHECK((is_iterable<map<int,int>>::value) == true);
CPPA_CHECK((is_iterable<map<int, int>>::value) == true);
{ // test meta_object implementation for primitive types
auto meta_int = uniform_typeid<uint32_t>();
CPPA_CHECK(meta_int != nullptr);
......
......@@ -14,8 +14,8 @@
#include "cppa/sb_actor.hpp"
#include "cppa/to_string.hpp"
#include "cppa/exit_reason.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/event_based_actor.hpp"
#include "cppa/util/callable_trait.hpp"
using namespace std;
using namespace cppa;
......@@ -275,7 +275,7 @@ void echo_actor() {
struct simple_mirror : sb_actor<simple_mirror> {
behavior init_state = (
others() >> []() {
others() >> [] {
reply_tuple(self->last_dequeued());
}
);
......@@ -314,25 +314,27 @@ struct high_priority_testee_class : event_based_actor {
int main() {
CPPA_TEST(test_spawn);
cout << "sizeof(event_based_actor) = " << sizeof(event_based_actor) << endl;
CPPA_PRINT("test send()");
send(self, 1, 2, 3, true);
receive(on(1, 2, 3, true) >> []() { });
receive(on(1, 2, 3, true) >> [] { });
self << any_tuple{};
receive(on() >> []() { });
receive(on() >> [] { });
CPPA_CHECKPOINT();
self << any_tuple{};
receive(on() >> []() { });
receive(on() >> [] { });
CPPA_PRINT("test receive with zero timeout");
receive (
others() >> CPPA_UNEXPECTED_MSG_CB(),
after(chrono::seconds(0)) >> []() { /* mailbox empty */ }
after(chrono::seconds(0)) >> [] { /* mailbox empty */ }
);
CPPA_CHECKPOINT();
CPPA_PRINT("test mirror"); {
auto mirror = spawn<simple_mirror,monitored>();
auto mirror = spawn<simple_mirror, monitored>();
send(mirror, "hello mirror");
receive (
on("hello mirror") >> CPPA_CHECKPOINT_CB(),
......@@ -348,7 +350,7 @@ int main() {
}
CPPA_PRINT("test detached mirror"); {
auto mirror = spawn<simple_mirror,monitored+detached>();
auto mirror = spawn<simple_mirror, monitored+detached>();
send(mirror, "hello mirror");
receive (
on("hello mirror") >> CPPA_CHECKPOINT_CB(),
......@@ -364,7 +366,7 @@ int main() {
}
CPPA_PRINT("test priority aware mirror"); {
auto mirror = spawn<simple_mirror,monitored+priority_aware>();
auto mirror = spawn<simple_mirror, monitored+priority_aware>();
CPPA_CHECKPOINT();
send(mirror, "hello mirror");
receive (
......@@ -384,7 +386,7 @@ int main() {
auto mecho = spawn(echo_actor);
send(mecho, "hello echo");
receive (
on("hello echo") >> []() { },
on("hello echo") >> [] { },
others() >> CPPA_UNEXPECTED_MSG_CB()
);
await_all_others_done();
......@@ -392,11 +394,11 @@ int main() {
CPPA_PRINT("test delayed_send()");
delayed_send(self, chrono::seconds(1), 1, 2, 3);
receive(on(1, 2, 3) >> []() { });
receive(on(1, 2, 3) >> [] { });
CPPA_CHECKPOINT();
CPPA_PRINT("test timeout");
receive(after(chrono::seconds(1)) >> []() { });
receive(after(chrono::seconds(1)) >> [] { });
CPPA_CHECKPOINT();
spawn(testee1);
......@@ -426,7 +428,7 @@ int main() {
on(atom("set_int"), arg_match) >> [i](int new_value) {
*i = new_value;
},
on(atom("done")) >> []() {
on(atom("done")) >> [] {
self->quit();
}
);
......@@ -481,7 +483,7 @@ int main() {
auto sync_testee1 = spawn<blocking_api>([] {
receive (
on(atom("get")) >> []() {
on(atom("get")) >> [] {
reply(42, 2);
}
);
......@@ -489,7 +491,7 @@ int main() {
send(self, 0, 0);
auto handle = sync_send(sync_testee1, atom("get"));
// wait for some time (until sync response arrived in mailbox)
receive (after(chrono::milliseconds(50)) >> []() { });
receive (after(chrono::milliseconds(50)) >> [] { });
// enqueue async messages (must be skipped by receive_response)
send(self, 42, 1);
// must skip sync message
......@@ -512,7 +514,7 @@ int main() {
// make sure there's no other message in our mailbox
receive (
others() >> CPPA_UNEXPECTED_MSG_CB(),
after(chrono::seconds(0)) >> []() { }
after(chrono::seconds(0)) >> [] { }
);
await_all_others_done();
CPPA_CHECKPOINT();
......@@ -530,7 +532,7 @@ int main() {
reply("goodbye!");
self->quit();
},
after(chrono::minutes(1)) >> []() {
after(chrono::minutes(1)) >> [] {
cerr << "PANIC!!!!" << endl;
abort();
}
......@@ -576,7 +578,7 @@ int main() {
on_arg_match >> [=](int n, const string& s) {
send(*receiver, n * 2, s);
},
on(atom("done")) >> []() {
on(atom("done")) >> [] {
self->quit();
}
);
......@@ -692,9 +694,9 @@ int main() {
// create some actors linked to one single actor
// and kill them all through killing the link
auto legion = spawn([] {
CPPA_LOGF_INFO("spawn 1,000 actors");
CPPA_LOGF_INFO("spawn 1, 000 actors");
for (int i = 0; i < 1000; ++i) {
spawn<event_testee,linked>();
spawn<event_testee, linked>();
}
become(others() >> CPPA_UNEXPECTED_MSG_CB());
});
......@@ -746,7 +748,7 @@ int main() {
spawn<priority_aware>(high_priority_testee);
await_all_others_done();
CPPA_CHECKPOINT();
spawn<high_priority_testee_class,priority_aware>();
spawn<high_priority_testee_class, priority_aware>();
await_all_others_done();
// don't try this at home, kids
send(self, atom("check"));
......
......@@ -21,9 +21,7 @@
#include "cppa/tpartial_function.hpp"
#include "cppa/uniform_type_info.hpp"
#include "cppa/util/rm_option.hpp"
#include "cppa/util/purge_refs.hpp"
#include "cppa/util/deduce_ref_type.hpp"
#include "cppa/util/type_traits.hpp"
#include "cppa/detail/matches.hpp"
#include "cppa/detail/projection.hpp"
......@@ -79,12 +77,12 @@ option<int> str2int(const std::string& str) {
#define CPPA_CHECK_INVOKED(FunName, Args) \
if ( ( FunName Args ) == false || invoked != #FunName ) { \
CPPA_FAILURE("invocation of " #FunName " failed"); \
CPPA_FAILURE("invocation of " #FunName " failed"); \
} invoked = ""
#define CPPA_CHECK_NOT_INVOKED(FunName, Args) \
if ( ( FunName Args ) == true || invoked == #FunName ) { \
CPPA_FAILURE(#FunName " erroneously invoked"); \
CPPA_FAILURE(#FunName " erroneously invoked"); \
} invoked = ""
struct dummy_receiver : event_based_actor {
......@@ -105,41 +103,41 @@ struct same_second_type : std::is_same<typename First::second, typename Second::
void check_type_list() {
using namespace cppa::util;
typedef type_list<int,int,int,float,int,float,float> zz0;
typedef type_list<int, int, int, float, int, float, float> zz0;
typedef type_list<type_list<int,int,int>,
typedef type_list<type_list<int, int, int>,
type_list<float>,
type_list<int>,
type_list<float,float>> zz8;
type_list<float, float>> zz8;
typedef type_list<
type_list<
type_pair<std::integral_constant<size_t,0>,int>,
type_pair<std::integral_constant<size_t,1>,int>,
type_pair<std::integral_constant<size_t,2>,int>
type_pair<std::integral_constant<size_t, 0>, int>,
type_pair<std::integral_constant<size_t, 1>, int>,
type_pair<std::integral_constant<size_t, 2>, int>
>,
type_list<
type_pair<std::integral_constant<size_t,3>,float>
type_pair<std::integral_constant<size_t, 3>, float>
>,
type_list<
type_pair<std::integral_constant<size_t,4>,int>
type_pair<std::integral_constant<size_t, 4>, int>
>,
type_list<
type_pair<std::integral_constant<size_t,5>,float>,
type_pair<std::integral_constant<size_t,6>,float>
type_pair<std::integral_constant<size_t, 5>, float>,
type_pair<std::integral_constant<size_t, 6>, float>
>
>
zz9;
typedef typename tl_group_by<zz0,std::is_same>::type zz1;
typedef typename tl_group_by<zz0, std::is_same>::type zz1;
typedef typename tl_zip_with_index<zz0>::type zz2;
static_assert(std::is_same<zz1,zz8>::value, "tl_group_by failed");
static_assert(std::is_same<zz1, zz8>::value, "tl_group_by failed");
typedef typename tl_group_by<zz2,same_second_type>::type zz3;
typedef typename tl_group_by<zz2, same_second_type>::type zz3;
static_assert(std::is_same<zz3,zz9>::value, "tl_group_by failed");
static_assert(std::is_same<zz3, zz9>::value, "tl_group_by failed");
}
void check_default_ctors() {
......@@ -357,7 +355,7 @@ void check_wildcards() {
CPPA_CHECK_EQUAL(get<0>(v0), "1"); // v0 contains old value
CPPA_CHECK(&get<0>(t0) != &get<0>(v0)); // no longer the same
// check operator==
auto lhs = make_cow_tuple(1,2,3,4);
auto lhs = make_cow_tuple(1, 2, 3, 4);
auto rhs = make_cow_tuple(static_cast<std::uint8_t>(1), 2.0, 3, 4);
CPPA_CHECK(lhs == rhs);
CPPA_CHECK(rhs == lhs);
......
......@@ -24,7 +24,7 @@
#include "cppa/detail/types_array.hpp"
#include "cppa/message_header.hpp"
#include "cppa/util/callable_trait.hpp"
#include "cppa/util/type_traits.hpp"
using std::cout;
using std::endl;
......@@ -122,9 +122,11 @@ int main() {
float, double,
atom_value, any_tuple, message_header,
actor_ptr, group_ptr,
channel_ptr, intrusive_ptr<process_information>
channel_ptr, process_information_ptr
>::arr;
CPPA_CHECK(sarr.is_pure());
std::vector<const uniform_type_info*> rarr{
uniform_typeid<std::int8_t>(),
uniform_typeid<std::int16_t>(),
......@@ -145,11 +147,9 @@ int main() {
uniform_typeid<actor_ptr>(),
uniform_typeid<group_ptr>(),
uniform_typeid<channel_ptr>(),
uniform_typeid<intrusive_ptr<process_information> >()
uniform_typeid<process_information_ptr>()
};
CPPA_CHECK_EQUAL(sarr.is_pure(), true);
for (size_t i = 0; i < sarr.size; ++i) {
CPPA_CHECK_EQUAL(sarr[i]->name(), rarr[i]->name());
CPPA_CHECK(sarr[i] == rarr[i]);
......
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