From 8302c2f33b2daacea2fba00015a8010c7d174e44 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 30 May 2019 08:34:17 -0700 Subject: [PATCH] fmt::internal::declval -> std::declval --- include/fmt/core.h | 19 ++++++++----------- include/fmt/format.h | 8 ++++---- include/fmt/ostream.h | 4 ++-- include/fmt/prepare.h | 20 ++++++++++---------- include/fmt/printf.h | 2 +- include/fmt/ranges.h | 19 +++++++++---------- test/prepare-test.cc | 15 ++++++--------- 7 files changed, 40 insertions(+), 47 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 6c93d5f6..b9685b52 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -206,10 +206,6 @@ FMT_BEGIN_NAMESPACE namespace internal { -// An implementation of declval for pre-C++11 compilers such as gcc 4. -template -typename std::add_rvalue_reference::type declval() FMT_NOEXCEPT; - template struct result_of; #if (__cplusplus >= 201703L || \ @@ -350,7 +346,8 @@ typedef char yes[1]; typedef char no[2]; template struct is_constructible { - template static yes& test(int (*)[sizeof(new U(declval()))]); + template + static yes& test(int (*)[sizeof(new U(std::declval()))]); template static no& test(...); enum { value = sizeof(test(nullptr)) == sizeof(yes) }; }; @@ -602,16 +599,16 @@ using fmt::v5::to_string_view; template struct is_string : std::integral_constant< - bool, !std::is_same()))>::value> { -}; + bool, + !std::is_same()))>::value> {}; // Forward declare FILE* specialization defined in color.h template <> struct is_string; template <> struct is_string; template struct char_t { - typedef decltype(to_string_view(declval())) result; + typedef decltype(to_string_view(std::declval())) result; typedef typename result::char_type type; }; @@ -1038,8 +1035,8 @@ class locale_ref { }; template struct get_type { - typedef decltype( - make_value(declval::type&>())) value_type; + typedef decltype(make_value( + std::declval::type&>())) value_type; static const type value = value_type::type_tag; }; diff --git a/include/fmt/format.h b/include/fmt/format.h index 8525639e..5fb25eb3 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -286,7 +286,7 @@ FMT_CONSTEXPR T* end(T (&array)[N]) FMT_NOEXCEPT { // An implementation of iterator_t for pre-C++20 compilers such as gcc 4. template struct iterator_t { - typedef decltype(internal::begin(internal::declval())) type; + typedef decltype(internal::begin(std::declval())) type; }; // For std::result_of in gcc 4.4. @@ -1393,7 +1393,7 @@ template class arg_formatter_base { public: typedef typename Range::value_type char_type; - typedef decltype(internal::declval().begin()) iterator; + typedef decltype(std::declval().begin()) iterator; typedef basic_format_specs format_specs; private: @@ -2388,7 +2388,7 @@ FMT_API void format_system_error(internal::buffer& out, int error_code, template class basic_writer { public: typedef typename Range::value_type char_type; - typedef decltype(internal::declval().begin()) iterator; + typedef decltype(std::declval().begin()) iterator; typedef basic_format_specs format_specs; private: @@ -3427,7 +3427,7 @@ template class is_output_iterator { // The compiler reveals this property only at the point of *actually // dereferencing* the iterator! template - static decltype(*(internal::declval())) test(std::input_iterator_tag); + static decltype(*(std::declval())) test(std::input_iterator_tag); template static char& test(std::output_iterator_tag); template static const char& test(...); diff --git a/include/fmt/ostream.h b/include/fmt/ostream.h index 4d7fd4b1..47d81a90 100644 --- a/include/fmt/ostream.h +++ b/include/fmt/ostream.h @@ -56,8 +56,8 @@ template struct test_stream : std::basic_ostream { template class is_streamable { private: template - static decltype((void)(internal::declval&>() - << internal::declval()), + static decltype((void)(std::declval&>() + << std::declval()), std::true_type()) test(int); diff --git a/include/fmt/prepare.h b/include/fmt/prepare.h index 913632fd..7bfe73d4 100644 --- a/include/fmt/prepare.h +++ b/include/fmt/prepare.h @@ -539,14 +539,14 @@ struct parts_container_concept_check : std::true_type { template static std::false_type has_add_check(check_second); template static decltype( - (void)declval().add(declval()), + (void)std::declval().add(std::declval()), std::true_type()) has_add_check(check_first); typedef decltype(has_add_check(check_first())) has_add; static_assert(has_add::value, "PartsContainer doesn't provide add() method"); template static std::false_type has_last_check(check_second); template - static decltype((void)declval().last(), + static decltype((void)std::declval().last(), std::true_type()) has_last_check(check_first); typedef decltype(has_last_check(check_first())) has_last; static_assert(has_last::value, @@ -555,8 +555,8 @@ struct parts_container_concept_check : std::true_type { template static std::false_type has_substitute_last_check(check_second); template - static decltype((void)declval().substitute_last( - declval()), + static decltype((void)std::declval().substitute_last( + std::declval()), std::true_type()) has_substitute_last_check(check_first); typedef decltype(has_substitute_last_check( check_first())) has_substitute_last; @@ -565,7 +565,7 @@ struct parts_container_concept_check : std::true_type { template static std::false_type has_begin_check(check_second); template - static decltype((void)declval().begin(), + static decltype((void)std::declval().begin(), std::true_type()) has_begin_check(check_first); typedef decltype(has_begin_check(check_first())) has_begin; static_assert(has_begin::value, @@ -573,7 +573,7 @@ struct parts_container_concept_check : std::true_type { template static std::false_type has_end_check(check_second); template - static decltype((void)declval().end(), + static decltype((void)std::declval().end(), std::true_type()) has_end_check(check_first); typedef decltype(has_end_check(check_first())) has_end; static_assert(has_end::value, "PartsContainer doesn't provide end() method"); @@ -626,19 +626,19 @@ class parts_container { format_part_type last() { return parts_.back(); } - auto begin() -> decltype(internal::declval().begin()) { + auto begin() -> decltype(std::declval().begin()) { return parts_.begin(); } - auto begin() const -> decltype(internal::declval().begin()) { + auto begin() const -> decltype(std::declval().begin()) { return parts_.begin(); } - auto end() -> decltype(internal::declval().end()) { + auto end() -> decltype(std::declval().end()) { return parts_.end(); } - auto end() const -> decltype(internal::declval().end()) { + auto end() const -> decltype(std::declval().end()) { return parts_.end(); } diff --git a/include/fmt/printf.h b/include/fmt/printf.h index 6c73b1d8..f879dc83 100644 --- a/include/fmt/printf.h +++ b/include/fmt/printf.h @@ -210,7 +210,7 @@ class printf_arg_formatter typename internal::arg_formatter_base::iterator>, public internal::arg_formatter_base { public: - typedef decltype(internal::declval().begin()) iterator; + typedef decltype(std::declval().begin()) iterator; private: typedef typename Range::value_type char_type; diff --git a/include/fmt/ranges.h b/include/fmt/ranges.h index f061699b..a3a0c7a0 100644 --- a/include/fmt/ranges.h +++ b/include/fmt/ranges.h @@ -94,21 +94,20 @@ template struct is_range_ : std::false_type {}; #if !FMT_MSC_VER || FMT_MSC_VER > 1800 template -struct is_range_< - T, typename std::conditional< - false, - conditional_helper().begin()), - decltype(internal::declval().end())>, - void>::type> : std::true_type {}; +struct is_range_().begin()), + decltype(std::declval().end())>, + void>::type> : std::true_type {}; #endif /// tuple_size and tuple_element check. template class is_tuple_like_ { template - static auto check(U* p) -> decltype( - std::tuple_size::value, - (void)internal::declval::type>(), - int()); + static auto check(U* p) + -> decltype(std::tuple_size::value, + (void)std::declval::type>(), + int()); template static void check(...); public: diff --git a/test/prepare-test.cc b/test/prepare-test.cc index 9985123d..64fe98c1 100644 --- a/test/prepare-test.cc +++ b/test/prepare-test.cc @@ -434,8 +434,8 @@ TEST(PrepareTest, CompileTimePreparedPartsTypeProvider) { // Use the struct instead of a function to workaround GCC 4.4's 'sorry, // unimplemented: mangling template_id_expr' issue. template struct copied_prepared_format_creator { - static decltype(fmt::prepare(fmt::internal::declval())) - make(std::string format_str) { + static decltype(fmt::prepare(std::declval())) make( + std::string format_str) { auto prepared_format = fmt::prepare(std::move(format_str)); auto copied_prepared_format = prepared_format; prepared_format = fmt::prepare(""); @@ -513,20 +513,17 @@ class custom_parts_container { format_part_type last() { return parts_.back(); } - auto begin() -> decltype(fmt::internal::declval().begin()) { + auto begin() -> decltype(std::declval().begin()) { return parts_.begin(); } - auto begin() const - -> decltype(fmt::internal::declval().begin()) { + auto begin() const -> decltype(std::declval().begin()) { return parts_.begin(); } - auto end() -> decltype(fmt::internal::declval().begin()) { - return parts_.end(); - } + auto end() -> decltype(std::declval().begin()) { return parts_.end(); } - auto end() const -> decltype(fmt::internal::declval().begin()) { + auto end() const -> decltype(std::declval().begin()) { return parts_.end(); }