mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-05-05 06:33:52 +00:00
Adding better boost testing on old compilers
This commit is contained in:
parent
9c700eca3e
commit
de06d50f34
@ -164,7 +164,7 @@ An option name must start with a alphabetic character or underscore. For long op
|
|||||||
|
|
||||||
On a C++14 compiler, you can pass a callback function directly to `.add_flag`, while in C++11 mode you'll need to use `.add_flag_function` if you want a callback function. The function will be given the number of times the flag was passed. You can throw a relevant `CLI::ParseError` to signal a failure.
|
On a C++14 compiler, you can pass a callback function directly to `.add_flag`, while in C++11 mode you'll need to use `.add_flag_function` if you want a callback function. The function will be given the number of times the flag was passed. You can throw a relevant `CLI::ParseError` to signal a failure.
|
||||||
|
|
||||||
On a compiler that supports C++17's `__has_include`, you can also use `std::optional`, `std::experimental::optional`, and `boost::optional` directly in an `add_option` call. See [CLI11 Internals] for information on how this was done and how you can add your own converters.
|
On a compiler that supports C++17's `__has_include`, you can also use `std::optional`, `std::experimental::optional`, and `boost::optional` directly in an `add_option` call. If you don't have `__has_include`, you can define `CLI11_BOOST_OPTIONAL` before including CLI11 to manually add support for `boost::optional`. See [CLI11 Internals] for information on how this was done and how you can add your own converters.
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
namespace CLI {
|
namespace CLI {
|
||||||
|
|
||||||
#ifdef CLI11_STD_OPTIONAL
|
#ifdef CLI11_STD_OPTIONAL
|
||||||
template <typename T> std::istream &operator>>(std::istream &in, std::optional<T> &val) {
|
template <typename T> std::istringstream &operator>>(std::istringstream &in, std::optional<T> &val) {
|
||||||
T v;
|
T v;
|
||||||
in >> v;
|
in >> v;
|
||||||
val = v;
|
val = v;
|
||||||
@ -38,7 +38,7 @@ template <typename T> std::istream &operator>>(std::istream &in, std::optional<T
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CLI11_EXPERIMENTAL_OPTIONAL
|
#ifdef CLI11_EXPERIMENTAL_OPTIONAL
|
||||||
template <typename T> std::istream &operator>>(std::istream &in, std::experimental::optional<T> &val) {
|
template <typename T> std::istringstream &operator>>(std::istringstream &in, std::experimental::optional<T> &val) {
|
||||||
T v;
|
T v;
|
||||||
in >> v;
|
in >> v;
|
||||||
val = v;
|
val = v;
|
||||||
|
@ -76,5 +76,9 @@ find_package(Boost 1.35)
|
|||||||
if(Boost_FOUND)
|
if(Boost_FOUND)
|
||||||
target_link_libraries(informational PUBLIC Boost::boost)
|
target_link_libraries(informational PUBLIC Boost::boost)
|
||||||
target_link_libraries(OptionalTest PUBLIC Boost::boost)
|
target_link_libraries(OptionalTest PUBLIC Boost::boost)
|
||||||
|
|
||||||
|
# Enforce Boost::Optional even if __has_include is missing on your compiler
|
||||||
|
target_compile_definitions(informational PUBLIC CLI11_BOOST_OPTIONAL)
|
||||||
|
target_compile_definitions(OptionalTest PUBLIC CLI11_BOOST_OPTIONAL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user