.. _program_listing_file__tmp_ws_src_proxsuite_include_proxsuite_helpers_optional.hpp: Program Listing for File optional.hpp ===================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/proxsuite/include/proxsuite/helpers/optional.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // // Copyright (c) 2022 INRIA // #ifndef PROXSUITE_HELPERS_OPTIONAL_HPP #define PROXSUITE_HELPERS_OPTIONAL_HPP #include #ifdef PROXSUITE_WITH_CPP_17 #include #else #include #endif namespace proxsuite { #ifdef PROXSUITE_WITH_CPP_17 template using optional = std::optional; using nullopt_t = std::nullopt_t; inline constexpr nullopt_t nullopt = std::nullopt; #else namespace detail { // Source boost: https://www.boost.org/doc/libs/1_74_0/boost/none.hpp // the trick here is to make instance defined once as a global but in a header // file template struct nullopt_instance { static const T instance; }; template const T nullopt_instance::instance = T(tl::nullopt); // global, but because 'tis a template, no cpp file required } // namespace detail template using optional = tl::optional; using nullopt_t = tl::nullopt_t; constexpr nullopt_t nullopt = detail::nullopt_instance::instance; #endif } // namespace proxsuite #endif /* end of include guard PROXSUITE_HELPERS_OPTIONAL_HPP */