diff --git a/google/cloud/internal/future_impl.cc b/google/cloud/internal/future_impl.cc index 388a480d23bd7..066318e49e837 100644 --- a/google/cloud/internal/future_impl.cc +++ b/google/cloud/internal/future_impl.cc @@ -17,46 +17,6 @@ #include "google/cloud/terminate_handler.h" #include -// This function is only needed if exceptions are enabled. -#ifdef GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS -// TODO(#14152): Remove libC++ hack -// The `std::future_error::future_error(std::future_errc)` constructor is not -// guaranteed to exist until C++17. Fortunately, stdlibc++, MSVC are forgiving, -// and libc++ is forgiving until version 18.1. -#if GOOGLE_CLOUD_CPP_CPP_VERSION >= 201703L || _LIBCPP_VERSION < 180100 - -namespace { -std::future_error MakeFutureErrorImpl(std::future_errc ec) { - return std::future_error(ec); -} -} // namespace - -#else -// We can probably tolerate this terrible hack (which depends on UB) until we -// require C++17. -namespace { -struct OhTheHorrors {}; -} // namespace - -namespace std { -template <> -class promise { - public: - static auto MakeFutureError(std::future_errc ec) { - return std::future_error(std::make_error_code(ec)); - } -}; -} // namespace std - -namespace { -std::future_error MakeFutureErrorImpl(std::future_errc ec) { - return std::promise::MakeFutureError(ec); -} -} // namespace - -#endif -#endif // GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS - namespace google { namespace cloud { GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_BEGIN @@ -65,7 +25,7 @@ namespace internal { [[noreturn]] void ThrowFutureError(std::future_errc ec, char const* msg) { #ifdef GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS (void)msg; // disable unused argument warning. - throw MakeFutureErrorImpl(ec); + throw std::future_error(ec); #else std::string full_msg = "future_error["; full_msg += std::make_error_code(ec).message(); @@ -87,7 +47,7 @@ namespace internal { std::exception_ptr MakeFutureError(std::future_errc ec) { #ifdef GOOGLE_CLOUD_CPP_HAVE_EXCEPTIONS - return std::make_exception_ptr(MakeFutureErrorImpl(ec)); + return std::make_exception_ptr(std::future_error(ec)); #else (void)ec; // We cannot create a valid `std::exception_ptr` in this case. It does not