|
2 | 2 | /* |
3 | 3 | * FakeIt - A Simplified C++ Mocking Framework |
4 | 4 | * Copyright (c) Eran Pe'er 2013 |
5 | | - * Generated: 2022-03-13 10:13:47.935387 |
| 5 | + * Generated: 2022-05-01 15:11:36.330620 |
6 | 6 | * Distributed under the MIT License. Please refer to the LICENSE file at: |
7 | 7 | * https://github.com/eranpeer/FakeIt |
8 | 8 | */ |
@@ -7726,11 +7726,36 @@ namespace fakeit { |
7726 | 7726 | struct ArgLocator { |
7727 | 7727 | template<typename current_arg, typename ...T, int ...N> |
7728 | 7728 | static void AssignArg(current_arg &&p, std::tuple<ArgValue<T, N>...> arg_vals) { |
7729 | | - if (std::get<check_index>(arg_vals).pos == arg_index) |
| 7729 | +#if __cplusplus >= 201703L |
| 7730 | + if constexpr (std::get<check_index>(arg_vals).pos == arg_index) |
7730 | 7731 | GetArg(std::forward<current_arg>(p)) = std::get<check_index>(arg_vals).value; |
| 7732 | +#else |
| 7733 | + if (std::get<check_index>(arg_vals).pos == arg_index) |
| 7734 | + Set(std::forward<current_arg>(p), std::get<check_index>(arg_vals).value); |
| 7735 | +#endif |
7731 | 7736 | else if (check_index > 0) |
7732 | 7737 | ArgLocator<arg_index, check_index - 1>::AssignArg(std::forward<current_arg>(p), arg_vals); |
7733 | 7738 | } |
| 7739 | + |
| 7740 | +#if __cplusplus < 201703L |
| 7741 | + private: |
| 7742 | + template<typename T, typename U> |
| 7743 | + static |
| 7744 | + typename std::enable_if<std::is_convertible<U, decltype(GetArg(std::declval<T>()))>::value, void>::type |
| 7745 | + Set(T &&p, U &&v) |
| 7746 | + { |
| 7747 | + GetArg(std::forward<T>(p)) = v; |
| 7748 | + } |
| 7749 | + |
| 7750 | + template<typename T, typename U> |
| 7751 | + static |
| 7752 | + typename std::enable_if<!std::is_convertible<U, decltype(GetArg(std::declval<T>()))>::value, void>::type |
| 7753 | + Set(T &&, U &&) |
| 7754 | + { |
| 7755 | + throw std::logic_error("ReturnAndSet(): Invalid value type"); |
| 7756 | + } |
| 7757 | +#endif |
| 7758 | + |
7734 | 7759 | }; |
7735 | 7760 |
|
7736 | 7761 | template<int arg_index> |
|
0 commit comments