#pragma once #include #include #ifdef VARIANT_COMPAT #include #else #include #endif // VARIANT_COMPAT namespace mlspp::tls { namespace var = std; // In a similar vein, we provide our own safe accessors for std::optional, since // std::optional::value() is not available on macOS 10.11. namespace opt { template T& get(std::optional& opt) { if (!opt) { throw std::runtime_error("bad_optional_access"); } return *opt; } template const T& get(const std::optional& opt) { if (!opt) { throw std::runtime_error("bad_optional_access"); } return *opt; } template T&& get(std::optional&& opt) { if (!opt) { throw std::runtime_error("bad_optional_access"); } return std::move(*opt); } template const T&& get(const std::optional&& opt) { if (!opt) { throw std::runtime_error("bad_optional_access"); } return std::move(*opt); } } // namespace opt } // namespace mlspp::tls