diff --git a/STL_Extension/include/CGAL/Pair_optional_adaptor.h b/STL_Extension/include/CGAL/Pair_optional_adaptor.h index b5e9ff22d81e..446471da3aec 100644 --- a/STL_Extension/include/CGAL/Pair_optional_adaptor.h +++ b/STL_Extension/include/CGAL/Pair_optional_adaptor.h @@ -17,16 +17,23 @@ namespace CGAL { // T is supposed to be a handle template -class Pair_optional_adaptor : public std::optional { +class Pair_optional_adaptor { public: - Pair_optional_adaptor(const std::optional& obj) : std::optional(obj), second(obj.has_value()), first(t_storage.t) { + Pair_optional_adaptor(const std::optional& obj) : first(), second(obj.has_value()) { if (obj.has_value()) - t_storage.t = *obj; - } //boost::tuples::detail::swallow_assign + first = *obj; + } + + Pair_optional_adaptor(const std::nullopt_t& obj) : first(), second(false) {} - Pair_optional_adaptor(const std::nullopt_t& obj) : std::optional(std::nullopt), second(false), first(t_storage.t) {} + Pair_optional_adaptor(std::pair& p) : first(p.first), second(p.second) {} - Pair_optional_adaptor(std::pair& p) : std::optional(p.second ? p.first : std::optional()), first(t_storage.t), second(p.second), t_storage(p.first) {} + operator std::optional() { + if (second) + return std::optional(first); + else + return std::nullopt; + } #ifndef CGAL_NO_DEPRECATED_CODE CGAL_DEPRECATED_MSG("you are using the deprecated API, please update your code") @@ -60,31 +67,22 @@ class Pair_optional_adaptor : public std::optional { } CGAL_DEPRECATED_MSG("you are using the deprecated API, please update your code") - operator std::tuple() { - return std::tuple(first, std::ignore); + operator std::tuple() { + return std::tuple(first, std::ignore); } CGAL_DEPRECATED_MSG("you are using the deprecated API, please update your code") - operator std::tuple() { - return std::tuple(std::ignore, second); + operator std::tuple() { + return std::tuple(std::ignore, second); } CGAL_DEPRECATED_MSG("you are using the deprecated API, please update your code") - operator std::tuple() { - return std::tuple(std::ignore, std::ignore); + operator std::tuple() { + return std::tuple(std::ignore, std::ignore); } #endif - - T &first; + T first; bool second; - -private: - union T_value { - T t; - int i; - T_value() : i(0) {} - T_value(T t) : t(t) {} - } t_storage; }; } // CGAL diff --git a/Surface_mesh/include/CGAL/Surface_mesh/Properties.h b/Surface_mesh/include/CGAL/Surface_mesh/Properties.h index 9bf03e97515e..6e4050b23cfa 100644 --- a/Surface_mesh/include/CGAL/Surface_mesh/Properties.h +++ b/Surface_mesh/include/CGAL/Surface_mesh/Properties.h @@ -23,6 +23,7 @@ #include #include #include +#include namespace CGAL {