Commit 368f2cd9a66f3808b77dfe73e56662d2b1788beb

Authored by Henry Fredrick Schreiner
Committed by Henry Schreiner
1 parent d2d4f07f

Fix for deprecated macro

include/CLI/Macros.hpp
... ... @@ -35,6 +35,8 @@ namespace CLI {
35 35  
36 36 #if defined(PYBIND11_CPP14)
37 37 #define CLI11_DEPRECATED(reason) [[deprecated(reason)]]
  38 +#elif defined(_MSC_VER)
  39 +#define CLI11_DEPRECATED(reason) __declspec(deprecated(reason))
38 40 #else
39 41 #define CLI11_DEPRECATED(reason) __attribute__((deprecated(reason)))
40 42 #endif
... ...
include/CLI/Option.hpp
... ... @@ -306,14 +306,17 @@ class Option : public OptionBase<Option> {
306 306 Option *requires(Option *opt) { return needs(opt); }
307 307  
308 308 /// Can find a string if needed \deprecated
309   - CLI11_DEPRECATED("Use needs instead of requires (eventual keyword clash)")
310   - template <typename T = App> Option *requires(std::string opt_name) { return needs<T>(opt_name); }
  309 + template <typename T = App> Option *requires(std::string opt_name) {
  310 + for(const Option_p &opt : dynamic_cast<T *>(parent_)->options_)
  311 + if(opt.get() != this && opt->check_name(opt_name))
  312 + return requires(opt.get());
  313 + throw IncorrectConstruction::MissingOption(opt_name);
  314 + }
311 315  
312 316 /// Any number supported, any mix of string and Opt \deprecated
313   - CLI11_DEPRECATED("Use needs instead of requires (eventual keyword clash)")
314 317 template <typename A, typename B, typename... ARG> Option *requires(A opt, B opt1, ARG... args) {
315   - needs(opt);
316   - return needs(opt1, args...);
  318 + requires(opt);
  319 + return requires(opt1, args...);
317 320 }
318 321 #endif
319 322  
... ...
tests/OptionalTest.cpp
... ... @@ -2,11 +2,11 @@
2 2 #include <iostream>
3 3  
4 4 #ifdef __has_include
5   -#if __has_include(<optional>)
  5 +#if defined(CLI11_CPP17) && __has_include(<optional>)
6 6 #include <optional>
7 7 #define have_optional 1
8 8 using std::experimental::optional;
9   -#elif __has_include(<experimental/optional>)
  9 +#elif defined(CPP11_CPP14) && __has_include(<experimental/optional>)
10 10 #include <experimental/optional>
11 11 #define have_optional 1
12 12 using std::optional;
... ...