| 5367 | |
| 5368 | template <typename T> |
| 5369 | TOML_NODISCARD |
| 5370 | inline optional<T> node::value_exact() const noexcept(impl::value_retrieval_is_nothrow<T>) |
| 5371 | { |
| 5372 | using namespace impl; |
| 5373 | |
| 5374 | static_assert(!is_wide_string<T> || TOML_ENABLE_WINDOWS_COMPAT, |
| 5375 | "Retrieving values as wide-character strings with node::value_exact() is only " |
| 5376 | "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled."); |
| 5377 | |
| 5378 | static_assert((is_native<T> || can_represent_native<T>)&&!is_cvref<T>, |
| 5379 | TOML_SA_VALUE_EXACT_FUNC_MESSAGE("return type of node::value_exact()")); |
| 5380 | |
| 5381 | // prevent additional compiler error spam when the static_assert fails by gating behind if constexpr |
| 5382 | if constexpr ((is_native<T> || can_represent_native<T>)&&!is_cvref<T>) |
| 5383 | { |
| 5384 | if (type() == node_type_of<T>) |
| 5385 | return { this->get_value_exact<T>() }; |
| 5386 | else |
| 5387 | return {}; |
| 5388 | } |
| 5389 | } |
| 5390 | |
| 5391 | template <typename T> |
| 5392 | TOML_NODISCARD |