proxsuite 0.6.7
The Advanced Proximal Optimization Toolbox
Loading...
Searching...
No Matches
optional.hpp
Go to the documentation of this file.
1//
2// Copyright (c) 2022 INRIA
3//
8#ifndef PROXSUITE_HELPERS_OPTIONAL_HPP
9#define PROXSUITE_HELPERS_OPTIONAL_HPP
10
11#include <proxsuite/fwd.hpp>
12
13#ifdef PROXSUITE_WITH_CPP_17
14#include <optional>
15#else
17#endif
18
19namespace proxsuite {
20#ifdef PROXSUITE_WITH_CPP_17
21template<class T>
22using optional = std::optional<T>;
23using nullopt_t = std::nullopt_t;
24inline constexpr nullopt_t nullopt = std::nullopt;
25#else
26namespace detail {
27// Source boost: https://www.boost.org/doc/libs/1_74_0/boost/none.hpp
28// the trick here is to make instance defined once as a global but in a header
29// file
30template<typename T>
32{
33 static const T instance;
34};
35template<typename T>
37 T(tl::nullopt); // global, but because 'tis a template, no cpp file required
38} // namespace detail
39template<class T>
43#endif
44} // namespace proxsuite
45
46#endif /* end of include guard PROXSUITE_HELPERS_OPTIONAL_HPP */
constexpr nullopt_t nullopt
Definition optional.hpp:42
tl::nullopt_t nullopt_t
Definition optional.hpp:41
tl::optional< T > optional
Definition optional.hpp:40
static constexpr nullopt_t nullopt
Represents an empty optional.
A tag type to represent an empty optional.