#pragma once // Distributed under the 3-Clause BSD License. See accompanying // file LICENSE or https://github.com/CLIUtils/CLI11 for details. #include #include "CLI/Macros.hpp" // [CLI11:verbatim] #ifdef __has_include #if defined(CLI11_CPP17) && __has_include() && \ defined(__cpp_lib_optional) && !defined(CLI11_STD_OPTIONAL) #define CLI11_STD_OPTIONAL #endif #if defined(CLI11_CPP14) && __has_include() && \ !defined(CLI11_EXPERIMENTAL_OPTIONAL) #define CLI11_EXPERIMENTAL_OPTIONAL #endif #if __has_include() && !defined(CLI11_BOOST_OPTIONAL) #include #if BOOST_VERSION >= 105800 #define CLI11_BOOST_OPTIONAL #endif #endif #endif #ifdef CLI11_STD_OPTIONAL #include #endif #ifdef CLI11_EXPERIMENTAL_OPTIONAL #include #endif #ifdef CLI11_BOOST_OPTIONAL #include #endif // [CLI11:verbatim] namespace CLI { #ifdef CLI11_STD_OPTIONAL template std::istream &operator>>(std::istream &in, std::optional &val) { T v; in >> v; val = v; return in; } #endif #ifdef CLI11_EXPERIMENTAL_OPTIONAL template std::istream &operator>>(std::istream &in, std::experimental::optional &val) { T v; in >> v; val = v; return in; } #endif #ifdef CLI11_BOOST_OPTIONAL template std::istream &operator>>(std::istream &in, boost::optional &val) { T v; in >> v; val = v; return in; } #endif // Export the best optional to the CLI namespace #if defined(CLI11_STD_OPTIONAL) using std::optional; #elif defined(CLI11_EXPERIMENTAL_OPTIONAL) using std::experimental::optional; #elif defined(CLI11_BOOST_OPTIONAL) using boost::optional; #endif // This is true if any optional is found #if defined(CLI11_STD_OPTIONAL) || defined(CLI11_EXPERIMENTAL_OPTIONAL) || defined(CLI11_BOOST_OPTIONAL) #define CLI11_OPTIONAL #endif } // namespace CLI