Commit e41694da authored by neverlord's avatar neverlord

maintenance

parent ebe6640a
...@@ -171,7 +171,6 @@ nobase_library_include_HEADERS = \ ...@@ -171,7 +171,6 @@ nobase_library_include_HEADERS = \
cppa/uniform_type_info.hpp \ cppa/uniform_type_info.hpp \
cppa/util/abstract_uniform_type_info.hpp \ cppa/util/abstract_uniform_type_info.hpp \
cppa/util/any_tuple_iterator.hpp \ cppa/util/any_tuple_iterator.hpp \
cppa/util/apply.hpp \
cppa/util/arg_match_t.hpp \ cppa/util/arg_match_t.hpp \
cppa/util/at.hpp \ cppa/util/at.hpp \
cppa/util/callable_trait.hpp \ cppa/util/callable_trait.hpp \
...@@ -186,11 +185,7 @@ nobase_library_include_HEADERS = \ ...@@ -186,11 +185,7 @@ nobase_library_include_HEADERS = \
cppa/util/either.hpp \ cppa/util/either.hpp \
cppa/util/element_at.hpp \ cppa/util/element_at.hpp \
cppa/util/enable_if.hpp \ cppa/util/enable_if.hpp \
cppa/util/eval_first_n.hpp \
cppa/util/eval_type_lists.hpp \
cppa/util/fiber.hpp \ cppa/util/fiber.hpp \
cppa/util/filter_type_list.hpp \
cppa/util/first_n.hpp \
cppa/util/fixed_vector.hpp \ cppa/util/fixed_vector.hpp \
cppa/util/has_copy_member_fun.hpp \ cppa/util/has_copy_member_fun.hpp \
cppa/util.hpp \ cppa/util.hpp \
......
...@@ -24,12 +24,10 @@ src/mock_scheduler.cpp ...@@ -24,12 +24,10 @@ src/mock_scheduler.cpp
cppa/actor.hpp cppa/actor.hpp
unit_testing/test__intrusive_ptr.cpp unit_testing/test__intrusive_ptr.cpp
cppa/util/concat_type_lists.hpp cppa/util/concat_type_lists.hpp
cppa/util/filter_type_list.hpp
cppa/util/is_comparable.hpp cppa/util/is_comparable.hpp
cppa/util/callable_trait.hpp cppa/util/callable_trait.hpp
unit_testing/test__type_list.cpp unit_testing/test__type_list.cpp
cppa/util/remove_const_reference.hpp cppa/util/remove_const_reference.hpp
cppa/util/eval_type_lists.hpp
cppa/util/compare_tuples.hpp cppa/util/compare_tuples.hpp
cppa/get.hpp cppa/get.hpp
cppa/detail/tdata.hpp cppa/detail/tdata.hpp
...@@ -49,7 +47,6 @@ cppa/detail/object_impl.hpp ...@@ -49,7 +47,6 @@ cppa/detail/object_impl.hpp
cppa/detail/swap_bytes.hpp cppa/detail/swap_bytes.hpp
src/serializer.cpp src/serializer.cpp
src/deserializer.cpp src/deserializer.cpp
cppa/util/eval_type_list.hpp
cppa/util/is_legal_tuple_type.hpp cppa/util/is_legal_tuple_type.hpp
cppa/util/replace_type.hpp cppa/util/replace_type.hpp
cppa/detail/serialize_tuple.hpp cppa/detail/serialize_tuple.hpp
...@@ -61,8 +58,6 @@ unit_testing/test__local_group.cpp ...@@ -61,8 +58,6 @@ unit_testing/test__local_group.cpp
unit_testing/hash_of.cpp unit_testing/hash_of.cpp
unit_testing/hash_of.hpp unit_testing/hash_of.hpp
cppa/detail/channel.hpp cppa/detail/channel.hpp
cppa/util/first_n.hpp
cppa/util/eval_first_n.hpp
cppa/local_actor.hpp cppa/local_actor.hpp
cppa/channel.hpp cppa/channel.hpp
src/channel.cpp src/channel.cpp
...@@ -96,7 +91,6 @@ cppa/detail/default_uniform_type_info_impl.hpp ...@@ -96,7 +91,6 @@ cppa/detail/default_uniform_type_info_impl.hpp
src/object.cpp src/object.cpp
cppa/util/comparable.hpp cppa/util/comparable.hpp
cppa/util/disable_if.hpp cppa/util/disable_if.hpp
cppa/util/apply.hpp
cppa/primitive_variant.hpp cppa/primitive_variant.hpp
cppa/primitive_type.hpp cppa/primitive_type.hpp
cppa/util/pt_token.hpp cppa/util/pt_token.hpp
......
...@@ -36,8 +36,6 @@ ...@@ -36,8 +36,6 @@
#include "cppa/primitive_type.hpp" #include "cppa/primitive_type.hpp"
#include "cppa/util/apply.hpp"
namespace cppa { namespace detail { namespace cppa { namespace detail {
// if (IfStmt == true) ptype = PT; else ptype = Else::ptype; // if (IfStmt == true) ptype = PT; else ptype = Else::ptype;
...@@ -68,8 +66,8 @@ struct type_to_ptype_impl : ...@@ -68,8 +66,8 @@ struct type_to_ptype_impl :
if_else_ptype<std::is_same<T, std::int16_t>, pt_int16, if_else_ptype<std::is_same<T, std::int16_t>, pt_int16,
if_else_ptype<std::is_same<T, std::int32_t>, pt_int32, if_else_ptype<std::is_same<T, std::int32_t>, pt_int32,
if_else_ptype<std::is_same<T, std::int64_t>, pt_int64, if_else_ptype<std::is_same<T, std::int64_t>, pt_int64,
if_else_ptype<std::is_same<T, std::uint8_t>, pt_uint8,
// unsigned integers // unsigned integers
if_else_ptype<std::is_same<T, std::uint8_t>, pt_uint8,
if_else_ptype<std::is_same<T, std::uint16_t>, pt_uint16, if_else_ptype<std::is_same<T, std::uint16_t>, pt_uint16,
if_else_ptype<std::is_same<T, std::uint32_t>, pt_uint32, if_else_ptype<std::is_same<T, std::uint32_t>, pt_uint32,
if_else_ptype<std::is_same<T, std::uint64_t>, pt_uint64, if_else_ptype<std::is_same<T, std::uint64_t>, pt_uint64,
...@@ -90,9 +88,7 @@ template<typename T> ...@@ -90,9 +88,7 @@ template<typename T>
struct type_to_ptype struct type_to_ptype
{ {
typedef typename util::apply<T, typedef typename std::remove_cv<typename std::remove_reference<T>::type>::type type;
std::remove_reference,
std::remove_cv >::type type;
static const primitive_type ptype = type_to_ptype_impl<type>::ptype; static const primitive_type ptype = type_to_ptype_impl<type>::ptype;
......
...@@ -40,10 +40,13 @@ ...@@ -40,10 +40,13 @@
#include "cppa/any_tuple.hpp" #include "cppa/any_tuple.hpp"
#include "cppa/tuple_view.hpp" #include "cppa/tuple_view.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp"
namespace cppa { namespace cppa {
template<typename... MatchRules> template<typename... MatchRules>
typename tuple_view_type_from_type_list<typename util::filter_type_list<anything, util::type_list<MatchRules...>>::type>::type typename tuple_view_type_from_type_list<typename util::lt_filter_not<util::type_list<MatchRules...>, util::tbind<std::is_same, anything>::type>::type>::type
get_view(any_tuple const& ut) get_view(any_tuple const& ut)
{ {
pattern<MatchRules...> p; pattern<MatchRules...> p;
......
...@@ -178,8 +178,7 @@ inline bool operator!=(object const& lhs, object const& rhs) ...@@ -178,8 +178,7 @@ inline bool operator!=(object const& lhs, object const& rhs)
template<typename T> template<typename T>
T& get_ref(object& obj) T& get_ref(object& obj)
{ {
static_assert(util::disjunction<std::is_pointer<T>, static_assert(!std::is_pointer<T>::value && !std::is_reference<T>::value,
std::is_reference<T>>::value == false,
"T is a reference or a pointer type."); "T is a reference or a pointer type.");
if (!(obj.type() == typeid(T))) if (!(obj.type() == typeid(T)))
{ {
...@@ -191,8 +190,7 @@ T& get_ref(object& obj) ...@@ -191,8 +190,7 @@ T& get_ref(object& obj)
template<typename T> template<typename T>
T const& get(object const& obj) T const& get(object const& obj)
{ {
static_assert(util::disjunction<std::is_pointer<T>, static_assert(!std::is_pointer<T>::value && !std::is_reference<T>::value,
std::is_reference<T>>::value == false,
"T is a reference or a pointer type."); "T is a reference or a pointer type.");
if (!(obj.type() == typeid(T))) if (!(obj.type() == typeid(T)))
{ {
......
...@@ -45,9 +45,7 @@ ...@@ -45,9 +45,7 @@
#include "cppa/util/type_list.hpp" #include "cppa/util/type_list.hpp"
#include "cppa/util/enable_if.hpp" #include "cppa/util/enable_if.hpp"
#include "cppa/util/arg_match_t.hpp" #include "cppa/util/arg_match_t.hpp"
#include "cppa/util/eval_first_n.hpp"
#include "cppa/util/callable_trait.hpp" #include "cppa/util/callable_trait.hpp"
#include "cppa/util/filter_type_list.hpp"
#include "cppa/util/concat_type_lists.hpp" #include "cppa/util/concat_type_lists.hpp"
#include "cppa/detail/boxed.hpp" #include "cppa/detail/boxed.hpp"
......
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
#include "cppa/any_tuple.hpp" #include "cppa/any_tuple.hpp"
#include "cppa/uniform_type_info.hpp" #include "cppa/uniform_type_info.hpp"
#include "cppa/util/tbind.hpp"
#include "cppa/util/type_list.hpp" #include "cppa/util/type_list.hpp"
#include "cppa/util/filter_type_list.hpp"
#include "cppa/detail/tdata.hpp" #include "cppa/detail/tdata.hpp"
#include "cppa/detail/types_array.hpp" #include "cppa/detail/types_array.hpp"
...@@ -68,7 +68,7 @@ class pattern<T0, Tn...> ...@@ -68,7 +68,7 @@ class pattern<T0, Tn...>
typedef util::type_list<T0, Tn...> tpl_args; typedef util::type_list<T0, Tn...> tpl_args;
typedef typename util::filter_type_list<anything, tpl_args>::type typedef typename util::lt_filter_not<tpl_args, util::tbind<std::is_same, anything>::type>::type
filtered_tpl_args; filtered_tpl_args;
typedef typename tuple_view_type_from_type_list<filtered_tpl_args>::type typedef typename tuple_view_type_from_type_list<filtered_tpl_args>::type
......
...@@ -31,16 +31,12 @@ ...@@ -31,16 +31,12 @@
#ifndef UTIL_HPP #ifndef UTIL_HPP
#define UTIL_HPP #define UTIL_HPP
#include "cppa/util/apply.hpp"
#include "cppa/util/callable_trait.hpp" #include "cppa/util/callable_trait.hpp"
#include "cppa/util/compare_tuples.hpp" #include "cppa/util/compare_tuples.hpp"
#include "cppa/util/concat_type_lists.hpp" #include "cppa/util/concat_type_lists.hpp"
#include "cppa/util/conjunction.hpp" #include "cppa/util/conjunction.hpp"
#include "cppa/util/disjunction.hpp" #include "cppa/util/disjunction.hpp"
#include "cppa/util/enable_if.hpp" #include "cppa/util/enable_if.hpp"
#include "cppa/util/eval_first_n.hpp"
#include "cppa/util/filter_type_list.hpp"
#include "cppa/util/first_n.hpp"
#include "cppa/util/has_copy_member_fun.hpp" #include "cppa/util/has_copy_member_fun.hpp"
#include "cppa/util/is_comparable.hpp" #include "cppa/util/is_comparable.hpp"
#include "cppa/util/is_copyable.hpp" #include "cppa/util/is_copyable.hpp"
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* 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 3 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 APPLY_HPP
#define APPLY_HPP
namespace cppa { namespace util {
template<class C, template <typename> class... Traits>
struct apply;
template<class C>
struct apply<C>
{
typedef C type;
};
template<class C,
template <typename> class Trait0,
template <typename> class... Traits>
struct apply<C, Trait0, Traits...>
{
typedef typename apply<typename Trait0<C>::type, Traits...>::type type;
};
} }
#endif // APPLY_HPP
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include "cppa/get.hpp" #include "cppa/get.hpp"
#include "cppa/util/at.hpp" #include "cppa/util/at.hpp"
#include "cppa/util/type_list.hpp" #include "cppa/util/type_list.hpp"
#include "cppa/util/eval_first_n.hpp"
#include "cppa/util/is_comparable.hpp" #include "cppa/util/is_comparable.hpp"
namespace cppa { namespace detail { namespace cppa { namespace detail {
...@@ -97,8 +96,8 @@ bool compare_first_elements(LhsTuple<LhsTypes...> const& lhs, ...@@ -97,8 +96,8 @@ bool compare_first_elements(LhsTuple<LhsTypes...> const& lhs,
typedef util::type_list<LhsTypes...> lhs_tlist; typedef util::type_list<LhsTypes...> lhs_tlist;
typedef util::type_list<RhsTypes...> rhs_tlist; typedef util::type_list<RhsTypes...> rhs_tlist;
typedef typename tl_first_n<cmp_size, lhs_tlist>::type lhs_sublist; typedef typename tl_first_n<lhs_tlist, cmp_size>::type lhs_sublist;
typedef typename tl_first_n<cmp_size, rhs_tlist>::type rhs_sublist; typedef typename tl_first_n<rhs_tlist, cmp_size>::type rhs_sublist;
typedef typename tl_zip<lhs_sublist, rhs_sublist>::type zipped_sublists; typedef typename tl_zip<lhs_sublist, rhs_sublist>::type zipped_sublists;
static_assert(tl_zipped_forall<zipped_sublists, is_comparable>::value, static_assert(tl_zipped_forall<zipped_sublists, is_comparable>::value,
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* 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 3 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 EVAL_FIRST_N_HPP
#define EVAL_FIRST_N_HPP
#include <type_traits>
#include "cppa/util/first_n.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/eval_type_lists.hpp"
namespace cppa { namespace util {
template <size_t N,
class ListA, class ListB,
template <typename, typename> class What>
struct eval_first_n;
template <size_t N, typename... TypesA, typename... TypesB,
template <typename, typename> class What>
struct eval_first_n<N, type_list<TypesA...>, type_list<TypesB...>, What>
{
typedef type_list<TypesA...> first_list;
typedef type_list<TypesB...> second_list;
typedef typename first_n<N, first_list>::type slist_a;
typedef typename first_n<N, second_list>::type slist_b;
static constexpr bool value = eval_type_lists<slist_a, slist_b, What>::value;
};
} } // namespace cppa::util
#endif // EVAL_FIRST_N_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* 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 3 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 EVAL_TYPE_LIST_HPP
#define EVAL_TYPE_LIST_HPP
#include "cppa/util/type_list.hpp"
#include "cppa/util/concat_type_lists.hpp"
namespace cppa { namespace util {
/**
* @brief Apply @p What to each element of @p List.
*/
template <class List, template <typename> class What>
struct eval_type_list
{
typedef typename List::head head;
typedef typename List::tail tail;
static constexpr bool value =
What<head>::value
&& eval_type_list<tail, What>::value;
};
template <template <typename> class What>
struct eval_type_list<type_list<>, What>
{
static constexpr bool value = true;
};
} } // namespace cppa::util
#endif // EVAL_TYPE_LIST_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* 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 3 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 EVAL_TYPE_LISTS_HPP
#define EVAL_TYPE_LISTS_HPP
#include <type_traits>
#include "cppa/util/type_list.hpp"
namespace cppa { namespace util {
/**
* @brief Apply @p What to each element of @p List.
*/
template <class ListA, class ListB,
template <typename, typename> class What>
struct eval_type_lists
{
typedef typename ListA::head head_a;
typedef typename ListA::tail tail_a;
typedef typename ListB::head head_b;
typedef typename ListB::tail tail_b;
static constexpr bool value =
!std::is_same<head_a, void_type>::value
&& !std::is_same<head_b, void_type>::value
&& What<head_a, head_b>::value
&& eval_type_lists<tail_a, tail_b, What>::value;
};
template <template <typename, typename> class What>
struct eval_type_lists<type_list<>, type_list<>, What>
{
static constexpr bool value = true;
};
} } // namespace cppa::util
#endif // EVAL_TYPE_LISTS_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* 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 3 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 FILTER_TYPE_LIST_HPP
#define FILTER_TYPE_LIST_HPP
#include "cppa/util/type_list.hpp"
namespace cppa { namespace util {
template<typename Needle, typename Haystack>
struct filter_type_list;
template<typename Needle, typename... Tail>
struct filter_type_list<Needle, util::type_list<Needle, Tail...>>
{
typedef typename filter_type_list<Needle, util::type_list<Tail...>>::type type;
};
template<typename Needle, typename... Tail>
struct filter_type_list<Needle, util::type_list<Needle*, Tail...>>
{
typedef typename filter_type_list<Needle, util::type_list<Tail...>>::type type;
};
template<typename Needle, typename Head, typename... Tail>
struct filter_type_list<Needle, util::type_list<Head, Tail...>>
{
typedef typename concat_type_lists<util::type_list<Head>, typename filter_type_list<Needle, util::type_list<Tail...>>::type>::type type;
};
template<typename Needle>
struct filter_type_list<Needle, util::type_list<>>
{
typedef util::type_list<> type;
};
} } // namespace cppa::util
#endif // FILTER_TYPE_LIST_HPP
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011, 2012 *
* 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 3 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 FIRST_N_HPP
#define FIRST_N_HPP
#include <cstddef>
#include <type_traits>
#include "cppa/util/at.hpp"
#include "cppa/util/wrapped.hpp"
#include "cppa/util/if_else.hpp"
#include "cppa/util/type_list.hpp"
#include "cppa/util/element_at.hpp"
#include "cppa/util/concat_type_lists.hpp"
namespace cppa { namespace detail {
template<size_t N, typename List>
struct n_
{
typedef typename util::element_at<N - 1, List>::type head;
typedef typename util::if_else<std::is_same<util::void_type, head>,
util::type_list<>,
util::wrapped<util::type_list<head>>>::type
head_list;
typedef typename n_<N - 1, List>::type tail_list;
typedef typename util::concat_type_lists<tail_list, head_list>::type type;
};
template<typename List>
struct n_<0, List>
{
typedef util::type_list<> type;
};
} } // namespace cppa::detail
namespace cppa { namespace util {
template<size_t N, typename List>
struct first_n;
template<size_t N, typename... ListTypes>
struct first_n<N, util::type_list<ListTypes...>>
{
typedef typename detail::n_<N, util::type_list<ListTypes...>>::type type;
};
} } // namespace cppa::util
#endif // FIRST_N_HPP
...@@ -38,8 +38,8 @@ namespace cppa { namespace util { ...@@ -38,8 +38,8 @@ namespace cppa { namespace util {
template<typename T> template<typename T>
struct is_legal_tuple_type struct is_legal_tuple_type
{ {
static constexpr bool value = std::is_pointer<T>::value == false static constexpr bool value = std::is_reference<T>::value == false
&& std::is_reference<T>::value == false && std::is_pointer<T>::value == false
&& std::is_array<T>::value == false; && std::is_array<T>::value == false;
}; };
......
...@@ -75,6 +75,8 @@ struct type_list<Head, Tail...> ...@@ -75,6 +75,8 @@ struct type_list<Head, Tail...>
}; };
// static list list::zip(list, list)
/** /**
* @brief Zips two lists of equal size. * @brief Zips two lists of equal size.
* *
...@@ -94,6 +96,8 @@ struct tl_zip<type_list<LhsElements...>, type_list<RhsElements...> > ...@@ -94,6 +96,8 @@ struct tl_zip<type_list<LhsElements...>, type_list<RhsElements...> >
typedef type_list<type_pair<LhsElements, RhsElements>...> type; typedef type_list<type_pair<LhsElements, RhsElements>...> type;
}; };
// list list::reverse()
template<class From, typename... Elements> template<class From, typename... Elements>
struct tl_reverse_impl; struct tl_reverse_impl;
...@@ -118,6 +122,8 @@ struct tl_reverse ...@@ -118,6 +122,8 @@ struct tl_reverse
typedef typename tl_reverse_impl<List>::type type; typedef typename tl_reverse_impl<List>::type type;
}; };
// bool list::find(type)
/** /**
* @brief Finds the first element of type @p What beginning at * @brief Finds the first element of type @p What beginning at
* index @p Pos. * index @p Pos.
...@@ -139,6 +145,8 @@ struct tl_find<type_list<Head, Tail...>, What, Pos> ...@@ -139,6 +145,8 @@ struct tl_find<type_list<Head, Tail...>, What, Pos>
: tl_find<type_list<Tail...>, What, Pos+1>::value; : tl_find<type_list<Tail...>, What, Pos+1>::value;
}; };
// list list::first_n(size_t)
template<size_t N, class List, typename... T> template<size_t N, class List, typename... T>
struct tl_first_n_impl; struct tl_first_n_impl;
...@@ -157,7 +165,7 @@ struct tl_first_n_impl<N, type_list<L0, L...>, T...> ...@@ -157,7 +165,7 @@ struct tl_first_n_impl<N, type_list<L0, L...>, T...>
/** /**
* @brief Creates a new list from the first @p N elements of @p List. * @brief Creates a new list from the first @p N elements of @p List.
*/ */
template<size_t N, class List> template<class List, size_t N>
struct tl_first_n struct tl_first_n
{ {
static_assert(N > 0, "N == 0"); static_assert(N > 0, "N == 0");
...@@ -165,6 +173,8 @@ struct tl_first_n ...@@ -165,6 +173,8 @@ struct tl_first_n
typedef typename tl_first_n_impl<N, List>::type type; typedef typename tl_first_n_impl<N, List>::type type;
}; };
// bool list::forall(predicate)
/** /**
* @brief Tests whether a predicate holds for all elements of a list. * @brief Tests whether a predicate holds for all elements of a list.
*/ */
...@@ -182,6 +192,8 @@ struct tl_forall<type_list<>, Predicate> ...@@ -182,6 +192,8 @@ struct tl_forall<type_list<>, Predicate>
static constexpr bool value = true; static constexpr bool value = true;
}; };
// bool list::zipped_forall(predicate)
/** /**
* @brief Tests whether a predicate holds for all elements of a zipped list. * @brief Tests whether a predicate holds for all elements of a zipped list.
*/ */
...@@ -200,6 +212,8 @@ struct tl_zipped_forall<type_list<>, Predicate> ...@@ -200,6 +212,8 @@ struct tl_zipped_forall<type_list<>, Predicate>
static constexpr bool value = true; static constexpr bool value = true;
}; };
// static list list::concat(list, list)
/** /**
* @brief Concatenates two lists. * @brief Concatenates two lists.
*/ */
...@@ -212,31 +226,47 @@ struct tl_concat<type_list<ListATypes...>, type_list<ListBTypes...> > ...@@ -212,31 +226,47 @@ struct tl_concat<type_list<ListATypes...>, type_list<ListBTypes...> >
typedef type_list<ListATypes..., ListBTypes...> type; typedef type_list<ListATypes..., ListBTypes...> type;
}; };
template<class List, typename Element>
struct tl_prepend;
template<typename E0, typename... E>
struct tl_prepend<type_list<E...>, E0>
{
typedef type_list<E0, E...> type;
};
// list list::appy(trait)
/** /**
* @brief Applies a "template function" to each element in the list. * @brief Applies a "template function" to each element in the list.
*/ */
template<typename List, template <typename> class What> template<typename List, template <typename> class Trait>
struct tl_apply; struct tl_apply;
template<template <typename> class What, typename... Elements> template<template <typename> class Trait, typename... Elements>
struct tl_apply<type_list<Elements...>, What> struct tl_apply<type_list<Elements...>, Trait>
{ {
typedef type_list<typename What<Elements>::type...> type; typedef type_list<typename Trait<Elements>::type...> type;
}; };
// list list::zipped_apply(trait)
/** /**
* @brief Applies a binary "template function" to each element * @brief Applies a binary "template function" to each element
* in the zipped list. * in the zipped list.
*/ */
template<typename List, template<typename, typename> class What> template<typename List, template<typename, typename> class Trait>
struct tl_zipped_apply; struct tl_zipped_apply;
template<template<typename, typename> class What, typename... T> template<template<typename, typename> class Trait, typename... T>
struct tl_zipped_apply<type_list<T...>, What> struct tl_zipped_apply<type_list<T...>, Trait>
{ {
typedef type_list<typename What<typename T::first, typename T::second>::type...> type; typedef type_list<typename Trait<typename T::first,
typename T::second>::type...> type;
}; };
// list list::pop_back()
/** /**
* @brief Creates a new list wih all but the last element of @p List. * @brief Creates a new list wih all but the last element of @p List.
*/ */
...@@ -247,6 +277,99 @@ struct tl_pop_back ...@@ -247,6 +277,99 @@ struct tl_pop_back
typedef typename tl_reverse<typename rlist::tail>::type type; typedef typename tl_reverse<typename rlist::tail>::type type;
}; };
// type list::at(size_t)
template<size_t N, typename... E>
struct lt_at_impl;
template<size_t N, typename E0, typename... E>
struct lt_at_impl<N, E0, E...>
{
typedef typename lt_at_impl<N-1, E...>::type type;
};
template<typename E0, typename... E>
struct lt_at_impl<0, E0, E...>
{
typedef E0 type;
};
/**
* @brief Gets element at index @p N of @p List.
*/
template<class List, size_t N>
struct lt_at;
template<size_t N, typename... E>
struct lt_at<type_list<E...>, N>
{
static_assert(N < sizeof...(E), "N >= List::size");
typedef typename lt_at_impl<N, E...>::type type;
};
// list list::prepend(type)
/**
* @brief Creates a new list with @p What prepended to @p List.
*/
template<class List, typename What>
struct lt_prepend;
template<typename What, typename... T>
struct lt_prepend<type_list<T...>, What>
{
typedef type_list<What, T...> type;
};
// list list::filter(predicate)
template<class List, bool... Selected>
struct lt_filter_impl;
template<>
struct lt_filter_impl< type_list<> >
{
typedef type_list<> type;
};
template<typename T0, typename... T, bool... S>
struct lt_filter_impl<type_list<T0, T...>, false, S...>
{
typedef typename lt_filter_impl<type_list<T...>, S...>::type type;
};
template<typename T0, typename... T, bool... S>
struct lt_filter_impl<type_list<T0, T...>, true, S...>
{
typedef typename lt_prepend<typename lt_filter_impl<type_list<T...>, S...>::type, T0>::type type;
};
/**
* @brief Create a new list containing all elements which satisfy @p Predicate.
*/
template<class List, template<typename> class Predicate>
struct lt_filter;
template<template<typename> class Predicate, typename... T>
struct lt_filter<type_list<T...>, Predicate>
{
typedef typename lt_filter_impl<type_list<T...>, Predicate<T>::value...>::type type;
};
/**
* @brief Create a new list containing all elements which
* do not satisfy @p Predicate.
*/
template<class List, template<typename> class Predicate>
struct lt_filter_not;
template<template<typename> class Predicate, typename... T>
struct lt_filter_not<type_list<T...>, Predicate>
{
typedef typename lt_filter_impl<type_list<T...>, !Predicate<T>::value...>::type type;
};
} } // namespace cppa::util } } // namespace cppa::util
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "cppa/detail/thread_pool_scheduler.hpp" #include "cppa/detail/thread_pool_scheduler.hpp"
// header for experimental stuff // header for experimental stuff
#include "cppa/util/filter_type_list.hpp"
#include "cppa/util/any_tuple_iterator.hpp" #include "cppa/util/any_tuple_iterator.hpp"
#define CPPA_TEST_CATCH_BLOCK() \ #define CPPA_TEST_CATCH_BLOCK() \
......
...@@ -40,7 +40,6 @@ ...@@ -40,7 +40,6 @@
#include "cppa/binary_serializer.hpp" #include "cppa/binary_serializer.hpp"
#include "cppa/binary_deserializer.hpp" #include "cppa/binary_deserializer.hpp"
#include "cppa/util/apply.hpp"
#include "cppa/util/pt_token.hpp" #include "cppa/util/pt_token.hpp"
#include "cppa/util/enable_if.hpp" #include "cppa/util/enable_if.hpp"
#include "cppa/util/disable_if.hpp" #include "cppa/util/disable_if.hpp"
......
...@@ -21,10 +21,6 @@ size_t test__type_list() ...@@ -21,10 +21,6 @@ size_t test__type_list()
CPPA_TEST(test__type_list); CPPA_TEST(test__type_list);
typedef apply<const int&, remove_const_reference>::type int_typedef;
CPPA_CHECK((is_same<int, int_typedef>::value));
typedef type_list<int, float, std::string> l1; typedef type_list<int, float, std::string> l1;
typedef typename tl_reverse<l1>::type r1; typedef typename tl_reverse<l1>::type r1;
......
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