mirror of
https://github.com/TartanLlama/optional.git
synced 2025-06-25 00:51:37 +02:00
More
This commit is contained in:
10
optional.hpp
10
optional.hpp
@ -29,17 +29,9 @@
|
||||
#endif
|
||||
|
||||
#if (defined(__GNUC__) && __GNUC__ == 5 && __GNUC_MINOR__ <= 4)
|
||||
#define TL_OPTIONAL_GCC54 1
|
||||
#else
|
||||
#define TL_OPTIONAL_GCC54 2
|
||||
#define TL_OPTIONAL_GCC54
|
||||
#endif
|
||||
|
||||
template <int> struct TC;
|
||||
TC<__GNUC__> debug_1;
|
||||
TC<__GNUC_MINOR__> debug_2;
|
||||
TC<TL_OPTIONAL_GCC54> debug_3;
|
||||
|
||||
|
||||
#if (defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ <= 9)
|
||||
#define TL_OPTIONAL_NO_CONSTRR
|
||||
#endif
|
||||
|
@ -11,6 +11,8 @@
|
||||
constexpr int get_int(int) { return 42; }
|
||||
TL_OPTIONAL_11_CONSTEXPR tl::optional<int> get_opt_int(int) { return 42; }
|
||||
|
||||
template <int> struct TC;
|
||||
|
||||
// What is Clang Format up to?!
|
||||
TEST_CASE("Monadic operations", "[monadic]") {
|
||||
SECTION("map") { // lhs is empty
|
||||
@ -122,8 +124,17 @@ TEST_CASE("Monadic operations", "[monadic]") {
|
||||
}
|
||||
|
||||
SECTION("map constexpr") {
|
||||
#if !defined(TL_OPTIONAL_GCC54)
|
||||
constexpr int i = 0;
|
||||
#else
|
||||
constexpr int i = 1;
|
||||
#endif
|
||||
|
||||
#if !defined(_MSC_VER) && !defined(TL_OPTIONAL_GCC49) && \
|
||||
!defined(TL_OPTIONAL_GCC54)
|
||||
|
||||
TC<i>{};
|
||||
|
||||
// test each overload in turn
|
||||
constexpr tl::optional<int> o16 = 42;
|
||||
constexpr auto o16r = o16.map(get_int);
|
||||
|
Reference in New Issue
Block a user