Commit 9abec963 authored by Dominik Charousset's avatar Dominik Charousset

Remove obsolete class detail::tuple_dummy

parent e5a74850
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENCE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_DETAIL_TUPLE_DUMMY_HPP
#define CAF_DETAIL_TUPLE_DUMMY_HPP
#include "caf/fwd.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/message_iterator.hpp"
namespace caf {
namespace detail {
struct tuple_dummy {
using types = detail::empty_type_list;
using const_iterator = message_iterator<tuple_dummy>;
inline size_t size() const { return 0; }
inline void* mutable_at(size_t) { return nullptr; }
inline const void* at(size_t) const { return nullptr; }
inline const uniform_type_info* type_at(size_t) const { return nullptr; }
inline const std::type_info* type_token() const {
return &typeid(detail::empty_type_list);
}
inline bool dynamically_typed() const { return false; }
inline const_iterator begin() const {
return {this};
}
inline const_iterator end() const {
return {this, 0};
}
};
} // namespace detail
} // namespace caf
#endif // CAF_DETAIL_TUPLE_DUMMY_HPP
......@@ -37,7 +37,6 @@
#include "caf/detail/matches.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/detail/lifted_fun.hpp"
#include "caf/detail/tuple_dummy.hpp"
#include "caf/detail/pseudo_tuple.hpp"
#include "caf/detail/behavior_impl.hpp"
......@@ -547,14 +546,12 @@ inline const message& detach_if_needed(const message& tup, std::false_type) {
return tup;
}
template <class Ptr>
void* fetch_native_data(Ptr& ptr, std::true_type) {
return ptr->mutable_native_data();
inline void* fetch_native_data(message& msg, std::true_type) {
return msg.empty() ? nullptr : msg.vals()->mutable_native_data();
}
template <class Ptr>
const void* fetch_native_data(const Ptr& ptr, std::false_type) {
return ptr->native_data();
inline const void* fetch_native_data(const message& msg, std::false_type) {
return msg.empty() ? nullptr : msg.vals()->native_data();
}
template <class T>
......@@ -723,23 +720,15 @@ class match_expr {
template <class Tuple>
result_type apply(Tuple& tup) {
idx_token_type idx_token;
if (tup.empty()) {
detail::tuple_dummy td;
auto td_token_ptr = td.type_token();
auto td_bitmask = get_cache_entry(td_token_ptr, td);
return detail::unroll_expr<result_type>(m_cases, td_bitmask, idx_token,
*td_token_ptr, false,
static_cast<void*>(nullptr), td);
}
std::integral_constant<bool, has_manipulator> mutator_token;
// returns either a reference or a new object
using detached = decltype(detail::detach_if_needed(tup, mutator_token));
detached tref = detail::detach_if_needed(tup, mutator_token);
auto& vals = tref.vals();
auto ndp = fetch_native_data(vals, mutator_token);
auto token_ptr = vals->type_token();
auto bitmask = get_cache_entry(token_ptr, *vals);
auto dynamically_typed = vals->dynamically_typed();
auto ndp = detail::fetch_native_data(tref, mutator_token);
auto token_ptr = tref.type_token();
auto bitmask = get_cache_entry(token_ptr, tref);
auto dynamically_typed = tref.dynamically_typed();
return detail::unroll_expr<result_type>(m_cases, bitmask, idx_token,
*token_ptr, dynamically_typed,
ndp, *vals);
......
......@@ -220,17 +220,13 @@ class message {
* The type token `&typeid(void)` indicates that this tuple is dynamically
* typed, i.e., the types where not available at compile time.
*/
inline const std::type_info* type_token() const {
return m_vals->type_token();
}
const std::type_info* type_token() const;
/**
* Checks whether this tuple is dynamically typed, i.e.,
* its types were not known at compile time.
*/
inline bool dynamically_typed() const {
return m_vals->dynamically_typed();
}
bool dynamically_typed() const;
/**
* Applies @p handler to this message and returns the result
......
......@@ -95,4 +95,12 @@ optional<message> message::apply(message_handler handler) {
return handler(*this);
}
const std::type_info* message::type_token() const {
return m_vals ? m_vals->type_token() : &typeid(detail::empty_type_list);
}
bool message::dynamically_typed() const {
return m_vals ? m_vals->dynamically_typed() : false;
}
} // namespace caf
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