diff --git a/libs/algorithm/test/copy.cpp b/libs/algorithm/test/copy.cpp index 07419a30..2db4c922 100644 --- a/libs/algorithm/test/copy.cpp +++ b/libs/algorithm/test/copy.cpp @@ -114,7 +114,7 @@ namespace testspr { array{{3, 4, 5, 6, 7, 8, 0, 0, 0, 0}} )); } - // !!! + // !!! BUG: sprout::fit::copy implementation requires ForwardIterator // { // SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy( // testspr::reduct_input(sprout::begin(arr1) + 2), @@ -139,7 +139,7 @@ namespace testspr { array{{3, 4, 5, 6}} )); } - // !!! + // !!! BUG: sprout::fit::copy implementation requires ForwardIterator // { // SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy( // testspr::reduct_input(sprout::begin(arr1) + 2), @@ -168,7 +168,7 @@ namespace testspr { array{{0, 0, 3, 4, 5, 6, 7, 8, 0, 0}} )); } - // !!! + // !!! BUG: sprout::fit::copy implementation requires ForwardIterator // { // SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy( // testspr::reduct_input(sprout::begin(arr1) + 2), diff --git a/sprout/cstdint.hpp b/sprout/cstdint.hpp index a0f81d8f..c8d00683 100644 --- a/sprout/cstdint.hpp +++ b/sprout/cstdint.hpp @@ -17,7 +17,7 @@ // SPROUT_INT[N]_C // SPROUT_UINT[N]_C // -#if SPROUT_CLANG_BETWEEN(3, 0, 0, 3, 3, 0) && !defined(__STDC_CONSTANT_MACROS) +#if SPROUT_CLANG_BETWEEN((3, 0, 0), (3, 3, 0)) && !defined(__STDC_CONSTANT_MACROS) # define SPROUT_INT8_C(n) n # define SPROUT_UINT8_C(n) n # define SPROUT_INT16_C(n) n diff --git a/sprout/detail/predef.hpp b/sprout/detail/predef.hpp index 047b4fba..5bb2e117 100644 --- a/sprout/detail/predef.hpp +++ b/sprout/detail/predef.hpp @@ -11,12 +11,31 @@ #include // -// SPROUT_IS_GCC +// SPROUT_VERSION_NUMBER +// +#define SPROUT_VERSION_NUMBER(major, minor, patch) \ + ((((major) % 100) * 10000000) + (((minor) % 100) * 100000) + ((patch) % 100000)) +// +// SPROUT_VERSION_NUMBER_ZERO +// +#define SPROUT_VERSION_NUMBER_ZERO \ + SPROUT_VERSION_NUMBER(0, 0, 0) + +// +// SPROUT_AVAILABLE_GCC // #if defined(__GNUC__) -# define SPROUT_IS_GCC (1) +# define SPROUT_AVAILABLE_GCC (1) #else -# define SPROUT_IS_GCC (0) +# define SPROUT_AVAILABLE_GCC (0) +#endif +// +// SPROUT_VERSION_GCC +// +#if SPROUT_AVAILABLE_GCC +# define SPROUT_VERSION_GCC SPROUT_VERSION_NUMBER(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) +#else +# define SPROUT_VERSION_GCC SPROUT_VERSION_NUMBER_ZERO #endif // // SPROUT_GCC_LESS @@ -24,55 +43,56 @@ // SPROUT_GCC_LESS_EQUAL // SPROUT_GCC_GREATER_EQUAL // -#if SPROUT_IS_GCC -# define SPROUT_GCC_LESS(major, minor, patch) ( \ - __GNUC__ < major \ - || (__GNUC__ == major && __GNUC_MINOR__ < minor) \ - || (__GNUC__ == major && __GNUC_MINOR__ == minor && __GNUC_PATCHLEVEL__ < patch) \ - ) -# define SPROUT_GCC_GREATER(major, minor, patch) ( \ - __GNUC__ > major \ - || (__GNUC__ == major && __GNUC_MINOR__ > minor) \ - || (__GNUC__ == major && __GNUC_MINOR__ == minor && __GNUC_PATCHLEVEL__ > patch) \ - ) -# define SPROUT_GCC_LESS_EQUAL(major, minor, patch) ( \ - __GNUC__ < major \ - || (__GNUC__ == major && __GNUC_MINOR__ < minor) \ - || (__GNUC__ == major && __GNUC_MINOR__ == minor && __GNUC_PATCHLEVEL__ <= patch) \ - ) -# define SPROUT_GCC_GREATER_EQUAL(major, minor, patch) ( \ - __GNUC__ > major \ - || (__GNUC__ == major && __GNUC_MINOR__ > minor) \ - || (__GNUC__ == major && __GNUC_MINOR__ == minor && __GNUC_PATCHLEVEL__ >= patch) \ - ) +#if SPROUT_AVAILABLE_GCC +# define SPROUT_GCC_LESS(major, minor, patch) \ + (SPROUT_VERSION_GCC < SPROUT_VERSION_NUMBER(major, minor, patch)) +# define SPROUT_GCC_GREATER(major, minor, patch) \ + (SPROUT_VERSION_GCC > SPROUT_VERSION_NUMBER(major, minor, patch)) +# define SPROUT_GCC_LESS_EQUAL(major, minor, patch) \ + (SPROUT_VERSION_GCC <= SPROUT_VERSION_NUMBER(major, minor, patch)) +# define SPROUT_GCC_GREATER_EQUAL(major, minor, patch) \ + (SPROUT_VERSION_GCC >= SPROUT_VERSION_NUMBER(major, minor, patch)) #else -# define SPROUT_GCC_LESS(major, minor, patch) (0) -# define SPROUT_GCC_GREATER(major, minor, patch) (0) -# define SPROUT_GCC_LESS_EQUAL(major, minor, patch) (0) -# define SPROUT_GCC_GREATER_EQUAL(major, minor, patch) (0) +# define SPROUT_GCC_LESS(major, minor, patch) \ + (0) +# define SPROUT_GCC_GREATER(major, minor, patch) \ + (0) +# define SPROUT_GCC_LESS_EQUAL(major, minor, patch) \ + (0) +# define SPROUT_GCC_GREATER_EQUAL(major, minor, patch) \ + (0) #endif // // SPROUT_GCC_BETWEEN // -#if SPROUT_IS_GCC -# define SPROUT_GCC_BETWEEN(major1, minor1, patch1, major2, minor2, patch2) \ - SPROUT_GCC_GREATER_EQUAL(major1, minor1, patch1) && SPROUT_GCC_LESS(major2, minor2, patch2) +#if SPROUT_AVAILABLE_GCC +# define SPROUT_GCC_BETWEEN(first_version, last_version) \ + (SPROUT_GCC_GREATER_EQUAL first_version && SPROUT_GCC_LESS last_version) #else -# define SPROUT_GCC_BETWEEN(major1, minor1, patch1, major2, minor2, patch2) (0) +# define SPROUT_GCC_BETWEEN(first_version, last_version) \ + (0) #endif // -// SPROUT_IS_CLANG +// SPROUT_AVAILABLE_CLANG // #if defined(__clang__) -# define SPROUT_IS_CLANG (1) +# define SPROUT_AVAILABLE_CLANG (1) #else -# define SPROUT_IS_CLANG (0) +# define SPROUT_AVAILABLE_CLANG (0) +#endif +// +// SPROUT_VERSION_CLANG +// +#if SPROUT_AVAILABLE_CLANG +# define SPROUT_VERSION_CLANG SPROUT_VERSION_NUMBER(__clang_major__, __clang_minor__, __clang_patchlevel__) +#else +# define SPROUT_VERSION_CLANG SPROUT_VERSION_NUMBER_ZERO #endif // // SPROUT_CLANG_HAS_FUTURE // -#if SPROUT_IS_CLANG +#if SPROUT_AVAILABLE_CLANG # define SPROUT_CLANG_HAS_FUTURE(future) (__has_feature(future)) #else # define SPROUT_CLANG_HAS_FUTURE(future) (0) @@ -83,41 +103,34 @@ // SPROUT_CLANG_LESS_EQUAL // SPROUT_CLANG_GREATER_EQUAL // -#if SPROUT_IS_CLANG -# define SPROUT_CLANG_LESS(major, minor, patch) ( \ - __clang_major__ < major \ - || (__clang_major__ == major && __clang_minor__ < minor) \ - || (__clang_major__ == major && __clang_minor__ == minor && __clang_patchlevel__ < patch) \ - ) -# define SPROUT_CLANG_GREATER(major, minor, patch) ( \ - __clang_major__ > major \ - || (__clang_major__ == major && __clang_minor__ > minor) \ - || (__clang_major__ == major && __clang_minor__ == minor && __clang_patchlevel__ > patch) \ - ) -# define SPROUT_CLANG_LESS_EQUAL(major, minor, patch) ( \ - __clang_major__ < major \ - || (__clang_major__ == major && __clang_minor__ < minor) \ - || (__clang_major__ == major && __clang_minor__ == minor && __clang_patchlevel__ <= patch) \ - ) -# define SPROUT_CLANG_GREATER_EQUAL(major, minor, patch) ( \ - __clang_major__ > major \ - || (__clang_major__ == major && __clang_minor__ > minor) \ - || (__clang_major__ == major && __clang_minor__ == minor && __clang_patchlevel__ >= patch) \ - ) +#if SPROUT_AVAILABLE_CLANG +# define SPROUT_CLANG_LESS(major, minor, patch) \ + (SPROUT_VERSION_CLANG < SPROUT_VERSION_NUMBER(major, minor, patch)) +# define SPROUT_CLANG_GREATER(major, minor, patch) \ + (SPROUT_VERSION_CLANG > SPROUT_VERSION_NUMBER(major, minor, patch)) +# define SPROUT_CLANG_LESS_EQUAL(major, minor, patch) \ + (SPROUT_VERSION_CLANG <= SPROUT_VERSION_NUMBER(major, minor, patch)) +# define SPROUT_CLANG_GREATER_EQUAL(major, minor, patch) \ + (SPROUT_VERSION_CLANG >= SPROUT_VERSION_NUMBER(major, minor, patch)) #else -# define SPROUT_CLANG_LESS(major, minor, patch) (0) -# define SPROUT_CLANG_GREATER(major, minor, patch) (0) -# define SPROUT_CLANG_LESS_EQUAL(major, minor, patch) (0) -# define SPROUT_CLANG_GREATER_EQUAL(major, minor, patch) (0) +# define SPROUT_CLANG_LESS(major, minor, patch) \ + (0) +# define SPROUT_CLANG_GREATER(major, minor, patch) \ + (0) +# define SPROUT_CLANG_LESS_EQUAL(major, minor, patch) \ + (0) +# define SPROUT_CLANG_GREATER_EQUAL(major, minor, patch) \ + (0) #endif // // SPROUT_CLANG_BETWEEN // -#if SPROUT_IS_CLANG -# define SPROUT_CLANG_BETWEEN(major1, minor1, patch1, major2, minor2, patch2) \ - SPROUT_CLANG_GREATER_EQUAL(major1, minor1, patch1) && SPROUT_CLANG_LESS(major2, minor2, patch2) +#if SPROUT_AVAILABLE_CLANG +# define SPROUT_CLANG_BETWEEN(first_version, last_version) \ + (SPROUT_CLANG_GREATER_EQUAL first_version && SPROUT_CLANG_LESS last_version) #else -# define SPROUT_CLANG_BETWEEN(major1, minor1, patch1, major2, minor2, patch2) (0) +# define SPROUT_CLANG_BETWEEN(first_version, last_version) \ + (0) #endif #endif // #ifndef SPROUT_DETAIL_PREDEF_HPP diff --git a/sprout/optional/optional.hpp b/sprout/optional/optional.hpp index 33b1f286..9a6556f4 100644 --- a/sprout/optional/optional.hpp +++ b/sprout/optional/optional.hpp @@ -107,7 +107,7 @@ namespace sprout { : init(v.init) , val(v.is_initialized() ? holder_type(*v) : holder_type()) {} -#if SPROUT_GCC_BETWEEN(4, 8, 0, 4, 8, 2) +#if SPROUT_GCC_BETWEEN((4, 8, 0), (4, 8, 2)) optional(optional&&) = default; #else SPROUT_CONSTEXPR optional(optional&& v) diff --git a/sprout/tuple/tuple/tuple_decl.hpp b/sprout/tuple/tuple/tuple_decl.hpp index d5c2868b..31e39ac4 100644 --- a/sprout/tuple/tuple/tuple_decl.hpp +++ b/sprout/tuple/tuple/tuple_decl.hpp @@ -189,7 +189,7 @@ namespace sprout { , base_type(sprout::forward(h)) {} tuple_impl(tuple_impl const&) = default; -#if SPROUT_GCC_BETWEEN(4, 8, 0, 4, 8, 2) +#if SPROUT_GCC_BETWEEN((4, 8, 0), (4, 8, 2)) tuple_impl(tuple_impl&&) = default; #else SPROUT_CONSTEXPR tuple_impl(tuple_impl&& t)