Skip to content

Commit

Permalink
Fix build on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverlord committed Jun 25, 2015
1 parent 9f36b67 commit e793c81
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
19 changes: 9 additions & 10 deletions libcaf_core/caf/detail/type_list.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ namespace detail {

/// A list of types.
template <class... Ts>
struct type_list { };
struct type_list {
constexpr type_list() {
// nop
}
};

/// Denotes the empty list.
using empty_type_list = type_list<>;
Expand Down Expand Up @@ -925,8 +929,8 @@ constexpr bool tlf_no_negative() {
return true;
}

template <class T, class... Ts>
constexpr bool tlf_no_negative(T x, Ts... xs) {
template <class... Ts>
constexpr bool tlf_no_negative(int x, Ts... xs) {
return x < 0 ? false : tlf_no_negative(xs...);
}

Expand All @@ -935,17 +939,12 @@ constexpr bool tlf_is_subset(type_list<Ts...>, List) {
return tlf_no_negative(tlf_find<Ts>(List{})...);
}

template <class ListA, class ListB>
constexpr bool tlf_is_subset() {
return tlf_is_subset(ListA{}, ListB{});
}

/// Tests whether ListA contains the same elements as ListB
/// and vice versa. This comparison ignores element positions.
template <class ListA, class ListB>
struct tl_equal {
static constexpr bool value = tlf_is_subset<ListA, ListB>()
&& tlf_is_subset<ListB, ListA>();
static constexpr bool value = tlf_is_subset(ListA{}, ListB{})
&& tlf_is_subset(ListB{}, ListA{});
};

template <size_t N, class T>
Expand Down
38 changes: 19 additions & 19 deletions libcaf_core/caf/typed_actor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,39 +87,39 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
/// Identifies the base class of brokers implementing this interface.
using broker_base = io::experimental::typed_broker<Sigs...>;

/// Stores the template parameter pack.
using signatures = detail::type_list<Sigs...>;

typed_actor() = default;
typed_actor(typed_actor&&) = default;
typed_actor(const typed_actor&) = default;
typed_actor& operator=(typed_actor&&) = default;
typed_actor& operator=(const typed_actor&) = default;

template <class... OtherSigs,
class Enable =
typename std::enable_if<
detail::tlf_is_subset<detail::type_list<Sigs...>,
detail::type_list<OtherSigs...>>()
>::type>
typed_actor(const typed_actor<OtherSigs...>& other) : ptr_(other.ptr_) {
template <class TypedActor,
class Enable = typename std::enable_if<
detail::tlf_is_subset(signatures{},
typename TypedActor::signatures{})
>::type>
typed_actor(const TypedActor& other) : ptr_(other.ptr_) {
// nop
}

template <class... OtherSigs,
class Enable =
typename std::enable_if<
detail::tlf_is_subset<detail::type_list<Sigs...>,
detail::type_list<OtherSigs...>>()
>::type>
typed_actor& operator=(const typed_actor<OtherSigs...>& other) {
template <class TypedActor,
class Enable = typename std::enable_if<
detail::tlf_is_subset(signatures{},
typename TypedActor::signatures{})
>::type>
typed_actor& operator=(const TypedActor& other) {
ptr_ = other.ptr_;
return *this;
}

template <class Impl,
class Enable =
typename std::enable_if<
detail::tlf_is_subset<detail::type_list<Sigs...>,
typename Impl::signatures>()
>::type>
class Enable = typename std::enable_if<
detail::tlf_is_subset(signatures{},
typename Impl::signatures{})
>::type>
typed_actor(intrusive_ptr<Impl> other) : ptr_(std::move(other)) {
// nop
}
Expand Down
8 changes: 4 additions & 4 deletions libcaf_core/test/metaprogramming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ CAF_TEST(metaprogramming) {
/* test tlf_is_subset */ {
using list_a = type_list<int, float, double>;
using list_b = type_list<float, int, double, std::string>;
CAF_CHECK((tlf_is_subset<list_a, list_b>()));
CAF_CHECK(! (tlf_is_subset<list_b, list_a>()));
CAF_CHECK((tlf_is_subset<list_a, list_a>()));
CAF_CHECK((tlf_is_subset<list_b, list_b>()));
CAF_CHECK((tlf_is_subset(list_a{}, list_b{})));
CAF_CHECK(! (tlf_is_subset(list_b{}, list_a{})));
CAF_CHECK((tlf_is_subset(list_a{}, list_a{})));
CAF_CHECK((tlf_is_subset(list_b{}, list_b{})));
}
}

0 comments on commit e793c81

Please sign in to comment.