| 108 | |
| 109 | template <typename T> |
| 110 | decltype(auto) get(int index_offset = 0) const { |
| 111 | using UT = meta::unqualified_t<T>; |
| 112 | int target = index + index_offset; |
| 113 | if constexpr (meta::is_optional_v<UT>) { |
| 114 | using ValueType = typename UT::value_type; |
| 115 | if constexpr (std::is_same_v<ValueType, error>) { |
| 116 | if (valid()) { |
| 117 | return UT(); |
| 118 | } |
| 119 | return UT(stack::stack_detail::get_error(L, target)); |
| 120 | } |
| 121 | else { |
| 122 | if (!valid()) { |
| 123 | return UT(); |
| 124 | } |
| 125 | return stack::get<UT>(L, target); |
| 126 | } |
| 127 | } |
| 128 | else { |
| 129 | if constexpr (std::is_same_v<T, error>) { |
| 130 | #if SOL_IS_ON(SOL_SAFE_PROXIES) |
| 131 | if (valid()) { |
| 132 | type t = type_of(L, target); |
| 133 | type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is an error)"); |
| 134 | } |
| 135 | #endif // Check Argument Safety |
| 136 | return stack::stack_detail::get_error(L, target); |
| 137 | } |
| 138 | else { |
| 139 | #if SOL_IS_ON(SOL_SAFE_PROXIES) |
| 140 | if (!valid()) { |
| 141 | type t = type_of(L, target); |
| 142 | type_panic_c_str(L, target, t, type::none, "bad get from protected_function_result (is not an error)"); |
| 143 | } |
| 144 | #endif // Check Argument Safety |
| 145 | return stack::get<T>(L, target); |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | #if SOL_IS_ON(SOL_COMPILER_GCC) |
| 151 | #pragma GCC diagnostic pop |
nothing calls this directly
no test coverage detected