File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
include/proxsuite/helpers Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,23 @@ using optional = std::optional<T>;
2121using nullopt_t = std::nullopt_t ;
2222inline constexpr nullopt_t nullopt = std::nullopt ;
2323#else
24+ namespace detail {
25+ // Source boost: https://www.boost.org/doc/libs/1_74_0/boost/none.hpp
26+ // the trick here is to make instance defined once as a global but in a header
27+ // file
28+ template <typename T>
29+ struct nullopt_instance
30+ {
31+ static const T instance;
32+ };
33+ template <typename T>
34+ const T nullopt_instance<T>::instance =
35+ T (tl::nullopt ); // global, but because 'tis a template, no cpp file required
36+ } // namespace detail
2437template <class T >
2538using optional = tl::optional<T>;
2639using nullopt_t = tl::nullopt_t ;
27- inline constexpr nullopt_t nullopt = tl::nullopt ;
40+ constexpr nullopt_t nullopt = detail::nullopt_instance< tl::nullopt_t >::instance ;
2841#endif
2942} // namespace proxsuite
3043
You can’t perform that action at this time.
0 commit comments