diff --git a/fit/function.h b/fit/function.h index 80b1f55..0c5ced4 100644 --- a/fit/function.h +++ b/fit/function.h @@ -35,12 +35,8 @@ #define FIT_CONST_FOLD(x) (__builtin_constant_p(x) ? (x) : (x)) #ifndef FIT_NO_UNIQUE_STATIC_FUNCTION_ADDR -#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 -#define FIT_NO_UNIQUE_STATIC_FUNCTION_ADDR 1 -#else #define FIT_NO_UNIQUE_STATIC_FUNCTION_ADDR 0 #endif -#endif namespace fit { @@ -50,7 +46,7 @@ namespace detail { template struct static_const { - static constexpr T value {}; + static constexpr T value = T(); }; template @@ -122,16 +118,20 @@ struct static_addr }} #if FIT_NO_UNIQUE_STATIC_FUNCTION_ADDR -#define FIT_STATIC_CONST_REF +#define FIT_DETAIL_STATIC_FUNCTION_AUTO FIT_STATIC_CONSTEXPR #else -#define FIT_STATIC_CONST_REF & +#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 +#define FIT_DETAIL_STATIC_FUNCTION_AUTO static auto& +#else +#define FIT_DETAIL_STATIC_FUNCTION_AUTO static constexpr auto& +#endif #endif #define FIT_DETAIL_MAKE_STATIC fit::detail::static_function_wrapper_factor() += true ? nullptr : fit::detail::static_addr() #define FIT_DETAIL_MAKE_REVEAL_STATIC(T) fit::detail::reveal_static_function_wrapper_factor() += true ? nullptr : fit::detail::static_addr() #define FIT_STATIC_FUNCTION(name) \ struct fit_private_static_function_ ## name {}; \ -static constexpr auto FIT_STATIC_CONST_REF name = FIT_DETAIL_MAKE_REVEAL_STATIC(fit_private_static_function_ ## name) +FIT_DETAIL_STATIC_FUNCTION_AUTO name = FIT_DETAIL_MAKE_REVEAL_STATIC(fit_private_static_function_ ## name) #endif diff --git a/test/test.h b/test/test.h index 74a082d..5ec6a30 100644 --- a/test/test.h +++ b/test/test.h @@ -39,12 +39,8 @@ struct name \ static fit::test::auto_register FIT_PP_CAT(name, _register) = fit::test::auto_register(name()); \ void name::operator()() const - template -constexpr bool is_empty(const T&) -{ - return std::is_empty::value; -} +T bare(const T&); }} @@ -65,7 +61,7 @@ constexpr bool is_empty(const T&) #else #define STATIC_ASSERT_NOT_DEFAULT_CONSTRUCTIBLE(T) static_assert(!std::is_default_constructible::value, "Default constructible") #endif -#define STATIC_ASSERT_EMPTY(x) static_assert(fit::test::is_empty(x), "Not empty"); +#define STATIC_ASSERT_EMPTY(x) static_assert(std::is_empty::value, "Not empty"); #define FIT_TEST_CASE() FIT_DETAIL_TEST_CASE(FIT_PP_CAT(test_, __LINE__))