isl_test_cpp17-generic.cc: work around std::optional::value issue in older macOS
authorSven Verdoolaege <sven.verdoolaege@gmail.com>
Sat, 20 Apr 2024 10:42:26 +0000 (20 12:42 +0200)
committerSven Verdoolaege <sven.verdoolaege@gmail.com>
Sat, 20 Apr 2024 10:42:26 +0000 (20 12:42 +0200)
In versions of macOS prior to 10.14, std::optional::value
is not available, while the compiler may still be detected
as supporting C++17.
While it would be possible to extend the detection
to include a check for std::optional::value, it is easy
enough to work around the absence of std::optional::value
by simply calling operator* on the std::optional.

Reported-by: Liviu Ionescu <ilg@livius.net>
Tested-by: Liviu Ionescu <ilg@livius.net>
Signed-off-by: Sven Verdoolaege <sven.verdoolaege@gmail.com>
isl_test_cpp17-generic.cc

index c6b4bab..c92ec14 100644 (file)
@@ -45,7 +45,7 @@ static void test_try_user(isl::ctx ctx)
 
        if (!maybe_int)
                die("integer cannot be retrieved from isl::id");
-       if (maybe_int.value() != 5)
+       if (*maybe_int != 5)
                die("wrong integer retrieved from isl::id");
        if (maybe_s)
                die("structure unexpectedly retrieved from isl::id");
@@ -60,7 +60,7 @@ static void test_try_user(isl::ctx ctx)
                auto maybe_s = id.try_user<std::shared_ptr<S>>();
                if (!maybe_s)
                        die("structure cannot be retrieved from isl::id");
-               if (maybe_s.value()->freed != &freed)
+               if ((*maybe_s)->freed != &freed)
                        die("invalid structure retrieved from isl::id");
        }
        if (!freed)