Commit 11444a4e3a2c1f760f6ab790dd099f76e273b2eb
Committed by
Henry Schreiner
1 parent
4d695b04
Updates to macros
Showing
2 changed files
with
20 additions
and
4 deletions
include/CLI/Macros.hpp
| ... | ... | @@ -9,21 +9,34 @@ namespace CLI { |
| 9 | 9 | |
| 10 | 10 | // The following version macro is very similar to the one in PyBind11 |
| 11 | 11 | |
| 12 | -#if !defined(_MSC_VER) && !defined(__INTEL_COMPILER) | |
| 12 | +#if !(defined(_MSC_VER) && __cplusplus == 199711L) && !defined(__INTEL_COMPILER) | |
| 13 | 13 | #if __cplusplus >= 201402L |
| 14 | 14 | #define CLI11_CPP14 |
| 15 | -#if __cplusplus > 201402L /* Temporary: should be updated to >= the final C++17 value once known */ | |
| 15 | +#if __cplusplus >= 201703L | |
| 16 | 16 | #define CLI11_CPP17 |
| 17 | +#if __cplusplus > 201703L | |
| 18 | +#define CLI11_CPP20 | |
| 17 | 19 | #endif |
| 18 | 20 | #endif |
| 19 | -#elif defined(_MSC_VER) | |
| 21 | +#endif | |
| 22 | +#elif defined(_MSC_VER) && __cplusplus == 199711L | |
| 20 | 23 | // MSVC sets _MSVC_LANG rather than __cplusplus (supposedly until the standard is fully implemented) |
| 24 | +// Unless you use the /Zc:__cplusplus flag on Visual Studio 2017 15.7 Preview 3 or newer | |
| 21 | 25 | #if _MSVC_LANG >= 201402L |
| 22 | 26 | #define CLI11_CPP14 |
| 23 | 27 | #if _MSVC_LANG > 201402L && _MSC_VER >= 1910 |
| 24 | 28 | #define CLI11_CPP17 |
| 29 | +#if __MSVC_LANG > 201703L && _MSC_VER >= 1910 | |
| 30 | +#define CLI11_CPP20 | |
| 31 | +#endif | |
| 25 | 32 | #endif |
| 26 | 33 | #endif |
| 27 | 34 | #endif |
| 28 | 35 | |
| 36 | +#if defined(PYBIND11_CPP14) | |
| 37 | +#define CLI11_DEPRECATED(reason) [[deprecated(reason)]] | |
| 38 | +#else | |
| 39 | +#define CLI11_DEPRECATED(reason) __attribute__((deprecated(reason))) | |
| 40 | +#endif | |
| 41 | + | |
| 29 | 42 | } // namespace CLI | ... | ... |
include/CLI/Option.hpp
| ... | ... | @@ -300,14 +300,17 @@ class Option : public OptionBase<Option> { |
| 300 | 300 | return needs(opt1, args...); |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | -#ifndef CLI11_CPP17 | |
| 303 | +#ifndef CLI11_CPP20 | |
| 304 | 304 | /// Sets required options \deprecated |
| 305 | + CLI11_DEPRECATED("Use needs instead of requires (eventual keyword clash)") | |
| 305 | 306 | Option *requires(Option *opt) { return needs(opt); } |
| 306 | 307 | |
| 307 | 308 | /// Can find a string if needed \deprecated |
| 309 | + CLI11_DEPRECATED("Use needs instead of requires (eventual keyword clash)") | |
| 308 | 310 | template <typename T = App> Option *requires(std::string opt_name) { return needs<T>(opt_name); } |
| 309 | 311 | |
| 310 | 312 | /// Any number supported, any mix of string and Opt \deprecated |
| 313 | + CLI11_DEPRECATED("Use needs instead of requires (eventual keyword clash)") | |
| 311 | 314 | template <typename A, typename B, typename... ARG> Option *requires(A opt, B opt1, ARG... args) { |
| 312 | 315 | needs(opt); |
| 313 | 316 | return needs(opt1, args...); | ... | ... |