Loading [MathJax]/extensions/TeX/AMSsymbols.js
Radium Engine  1.5.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
StdOptional.hpp
1 #pragma once
2 
3 /*
4  * This file provides
5  * - Ra::Core::Utils::optional, which is an alias for std::optional or std::experimental::optional,
6  * - preprocessor symbols:
7  * - have_optional: defined if optional is found in std:: or in std::experimental::
8  * - have_experimental_optional: defined iff optional is found in std::experimental::
9  *
10  * To trigger an error if optional is not found, define RA_REQUIRE_OPTIONAL before including this
11  * file:
12  * \code{.cpp}
13  * #define RA_REQUIRE_OPTIONAL
14  * #include <Core/Utils/StdOptional.hpp> // trigger an error if optional is not found
15  * #undef RA_REQUIRE_OPTIONAL
16  * \endcode
17  */
18 
19 #ifdef __has_include
20 # if __has_include( <optional>)
21 # include <optional>
22 # define have_optional
23 # elif __has_include( <experimental/optional>)
24 # include <experimental/optional>
25 # define have_optional
26 # define have_experimental_optional
27 # else
28 # ifdef RA_REQUIRE_OPTIONAL
29 # error Feature Optionnal is required
30 # endif
31 # endif
32 #endif
33 
34 // Create alias
35 #ifdef have_optional
36 namespace Ra {
37 namespace Core {
38 namespace Utils {
39 # ifdef have_experimental_optional
40 template <typename T>
41 using optional = std::experimental::optional<T>;
42 # else
43 template <typename T>
44 using optional = std::optional<T>;
45 # endif
46 } // namespace Utils
47 } // namespace Core
48 } // namespace Ra
49 #endif
50 // end Create alias
Definition: Cage.cpp:3