From 16e11da8449f7a40bd91b0ca57db8df7bd260571 Mon Sep 17 00:00:00 2001 From: badair Date: Fri, 15 Apr 2016 21:57:44 -0500 Subject: [PATCH] working toward gcc 4.8 support --- .travis.yml | 14 +++++++------- include/callable_traits/config.hpp | 6 ++++++ include/callable_traits/detail/bind_expression.hpp | 5 +++-- include/callable_traits/detail/can_invoke_impl.hpp | 2 +- test/bind_1.cpp | 4 ++-- test/bind_2.cpp | 4 ++-- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8b8a371..a20ff0b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,13 +85,13 @@ matrix: sources: *sources # GCC 4.8 - #- env: UNIT_TESTS=true CPP=1y COMPILER=g++-4.8 STDLIB=libstdc++ - # os: linux - # compiler: g++ - # addons: - # apt: - # packages: ["g++-4.8"] - # sources: *sources + - env: UNIT_TESTS=true CPP=1y COMPILER=g++-4.8 STDLIB=libstdc++ + os: linux + compiler: g++ + addons: + apt: + packages: ["g++-4.8"] + sources: *sources before_install: diff --git a/include/callable_traits/config.hpp b/include/callable_traits/config.hpp index 2e2324e..0a54601 100644 --- a/include/callable_traits/config.hpp +++ b/include/callable_traits/config.hpp @@ -14,6 +14,12 @@ Distributed under the Boost Software License, Version 1.0. #define CALLABLE_TRAITS_MAKE_IX_SEQ(...) ::std::make_index_sequence< __VA_ARGS__ > #define CALLABLE_TRAITS_DISJUNCTION(...) ::std::disjunction< __VA_ARGS__ > #define CALLABLE_TRAITS_CONJUNCTION(...) ::std::conjunction< __VA_ARGS__ > +#define CALLALBLE_TRAITS_DECLTYPE_AUTO decltype(auto) + +#ifndef __cpp_decltype_auto +#undef CALLALBLE_TRAITS_DECLTYPE_AUTO +#define CALLALBLE_TRAITS_DECLTYPE_AUTO auto +#endif #ifndef __cpp_lib_logical_traits #include diff --git a/include/callable_traits/detail/bind_expression.hpp b/include/callable_traits/detail/bind_expression.hpp index 0bdaeb2..ec92aa9 100644 --- a/include/callable_traits/detail/bind_expression.hpp +++ b/include/callable_traits/detail/bind_expression.hpp @@ -112,7 +112,8 @@ namespace callable_traits { template>::value, int>::type = 0> - inline constexpr decltype(auto) unwrap_std_bind(T&& t){ + inline constexpr CALLALBLE_TRAITS_DECLTYPE_AUTO + unwrap_std_bind(T&& t){ return t.get_std_bind(); } @@ -174,7 +175,7 @@ namespace callable_traits { unwrap_std_bind(static_cast(args))...)) {} template - inline decltype(auto) + inline CALLALBLE_TRAITS_DECLTYPE_AUTO operator()(Rgs&&... args) { return std_bind(std::forward(args)...); } diff --git a/include/callable_traits/detail/can_invoke_impl.hpp b/include/callable_traits/detail/can_invoke_impl.hpp index facb538..8a37f76 100644 --- a/include/callable_traits/detail/can_invoke_impl.hpp +++ b/include/callable_traits/detail/can_invoke_impl.hpp @@ -11,7 +11,7 @@ namespace callable_traits { namespace detail { template - inline constexpr decltype(auto) + inline constexpr auto can_invoke_impl(T&& t, Args&&... args) { using traits = detail::traits; using test = detail::test_invoke; diff --git a/test/bind_1.cpp b/test/bind_1.cpp index c2c66fb..e56cad1 100644 --- a/test/bind_1.cpp +++ b/test/bind_1.cpp @@ -68,13 +68,13 @@ auto ordered_letters(A a, B b, C c, D d, E e, F f, G g) { } template -constexpr decltype(auto) +constexpr auto apply_helper(F&& f, Tuple&& t, CALLABLE_TRAITS_IX_SEQ(I...)) { return std::forward(f)(std::get(std::forward(t))...); } template -constexpr decltype(auto) +constexpr auto apply(F&& f, Tuple&& t) { return apply_helper( std::forward(f), diff --git a/test/bind_2.cpp b/test/bind_2.cpp index 1e7f3d1..d962115 100644 --- a/test/bind_2.cpp +++ b/test/bind_2.cpp @@ -70,14 +70,14 @@ auto BEEF_returns_B(B, E, E, F) { } template -constexpr decltype(auto) +constexpr auto apply_helper(F&& f, Tuple&& t, CALLABLE_TRAITS_IX_SEQ(I...)) { return std::forward(f)(std::get(std::forward(t))...); } //used to apply the expected_args tuple to std::bind template -constexpr decltype(auto) +constexpr auto apply(F&& f, Tuple&& t) { return apply_helper( std::forward(f),