Commit 5419fb4d authored by Dominik Charousset's avatar Dominik Charousset

GCC 4.8 compatibility

the most recent changes to GCC broke some SFINAE code libcppa, this patch
solves this issue
parent 40689a3d
...@@ -52,52 +52,34 @@ namespace cppa { namespace detail { ...@@ -52,52 +52,34 @@ namespace cppa { namespace detail {
typedef std::unique_ptr<uniform_type_info> unique_uti; typedef std::unique_ptr<uniform_type_info> unique_uti;
// check if there's a 'push_back' that takes a C::value_type
template<typename T> template<typename T>
class is_stl_compliant_list { char is_stl_compliant_list_fun(T* ptr,
typename T::value_type* val = nullptr,
decltype(ptr->push_back(*val))* = nullptr);
template<class C> long is_stl_compliant_list_fun(void*); // SFNINAE default
static bool cmp_help_fun (
// mutable pointer
C* mc,
// check if there's a 'void push_back()' that takes C::value_type
decltype(mc->push_back(typename C::value_type()))* = nullptr
) {
return true;
}
// SFNINAE default
static void cmp_help_fun(void*) { }
typedef decltype(cmp_help_fun(static_cast<T*>(nullptr))) result_type;
public: template<typename T>
struct is_stl_compliant_list {
static constexpr bool value = util::is_iterable<T>::value
&& std::is_same<bool, result_type>::value;
static constexpr bool value = util::is_iterable<T>::value &&
sizeof(is_stl_compliant_list_fun(static_cast<T*>(nullptr))) == sizeof(char);
}; };
// check if there's an 'insert' that takes a C::value_type
template<typename T> template<typename T>
class is_stl_compliant_map { char is_stl_compliant_map_fun(T* ptr,
typename T::value_type* val = nullptr,
decltype(ptr->insert(*val))* = nullptr);
template<class C> long is_stl_compliant_map_fun(void*); // SFNINAE default
static bool cmp_help_fun (
// mutable pointer
C* mc,
// check if there's an 'insert()' that takes C::value_type
decltype(mc->insert(typename C::value_type()))* = nullptr
) {
return true;
}
static void cmp_help_fun(void*) { }
typedef decltype(cmp_help_fun(static_cast<T*>(nullptr))) result_type;
public: template<typename T>
struct is_stl_compliant_map {
static constexpr bool value = util::is_iterable<T>::value static constexpr bool value = util::is_iterable<T>::value &&
&& std::is_same<bool, result_type>::value; sizeof(is_stl_compliant_map_fun(static_cast<T*>(nullptr))) == sizeof(char);
}; };
......
...@@ -147,6 +147,14 @@ struct raw_struct_type_info : util::abstract_uniform_type_info<raw_struct> { ...@@ -147,6 +147,14 @@ struct raw_struct_type_info : util::abstract_uniform_type_info<raw_struct> {
int main() { int main() {
CPPA_TEST(test_serialization); CPPA_TEST(test_serialization);
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);
CPPA_CHECK_EQUAL(detail::is_stl_compliant_map<strmap>::value, true);
CPPA_CHECK_EQUAL(detail::impl_id<strmap>(), 2);
CPPA_CHECK_EQUAL(token::value, 2);
announce(typeid(raw_struct), new raw_struct_type_info); announce(typeid(raw_struct), new raw_struct_type_info);
network::default_actor_addressing addressing; network::default_actor_addressing addressing;
......
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