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