diff --git a/include/fmt/compile.h b/include/fmt/compile.h index ec79d05e..5beb6aa5 100644 --- a/include/fmt/compile.h +++ b/include/fmt/compile.h @@ -100,19 +100,17 @@ template struct format_part { template class format_preparation_handler : public internal::error_handler { private: - typedef format_part part; + using part = format_part; public: - typedef typename basic_string_view::iterator iterator; + using iterator = typename basic_string_view::iterator; FMT_CONSTEXPR format_preparation_handler(basic_string_view format, PartsContainer& parts) : parts_(parts), format_(format), parse_context_(format) {} FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) { - if (begin == end) { - return; - } + if (begin == end) return; const auto offset = begin - format_.data(); const auto size = end - begin; parts_.add(part(string_view_metadata(offset, size))); @@ -143,14 +141,12 @@ class format_preparation_handler : public internal::error_handler { const Char* end) { const auto specs_offset = to_unsigned(begin - format_.begin()); - typedef basic_parse_context parse_context; + using parse_context = basic_parse_context; internal::dynamic_format_specs parsed_specs; dynamic_specs_handler handler(parsed_specs, parse_context_); begin = parse_format_specs(begin, end, handler); - if (*begin != '}') { - on_error("missing '}' in format string"); - } + if (*begin != '}') on_error("missing '}' in format string"); const auto last_part = parts_.last(); @@ -185,7 +181,7 @@ class prepared_format { prepared_format() = delete; - typedef buffer_context context; + using context = buffer_context; template auto vformat_to(Range out, basic_format_args args) const -> @@ -288,9 +284,7 @@ template class compiletime_prepared_parts_type_provider { FMT_CONSTEXPR count_handler() : counter_(0u) {} FMT_CONSTEXPR void on_text(const char_type* begin, const char_type* end) { - if (begin != end) { - ++counter_; - } + if (begin != end) ++counter_; } FMT_CONSTEXPR void on_arg_id() { ++counter_; } @@ -316,13 +310,10 @@ template class compiletime_prepared_parts_type_provider { if (*begin == '{') { ++braces_counter; } else if (*begin == '}') { - if (braces_counter == 0u) { - break; - } + if (braces_counter == 0u) break; --braces_counter; } } - return begin; } @@ -348,7 +339,7 @@ template class compiletime_prepared_parts_type_provider { public: template struct format_parts_array { - typedef format_part value_type; + using value_type = format_part; FMT_CONSTEXPR format_parts_array() : arr{} {} @@ -364,7 +355,7 @@ template class compiletime_prepared_parts_type_provider { struct empty { // Parts preparator will search for it - typedef format_part value_type; + using value_type = format_part; }; using type = conditional_t(number_of_format_parts), @@ -373,7 +364,7 @@ template class compiletime_prepared_parts_type_provider { template class compiletime_prepared_parts_collector { private: - typedef typename Parts::value_type format_part; + using format_part = typename Parts::value_type; public: FMT_CONSTEXPR explicit compiletime_prepared_parts_collector(Parts& parts) @@ -403,7 +394,7 @@ FMT_CONSTEXPR PartsContainer prepare_parts(basic_string_view format) { template FMT_CONSTEXPR PartsContainer prepare_compiletime_parts(basic_string_view format) { - typedef compiletime_prepared_parts_collector collector; + using collector = compiletime_prepared_parts_collector; PartsContainer parts; collector c(parts); @@ -454,7 +445,7 @@ struct parts_container_concept_check : std::true_type { : std::true_type {}; static_assert(has_format_part_type::value, - "PartsContainer doesn't provide format_part_type typedef"); + "PartsContainer doesn't provide format_part_type"); struct check_second {}; struct check_first : check_second {}; @@ -464,14 +455,14 @@ struct parts_container_concept_check : std::true_type { static decltype( (void)std::declval().add(std::declval()), std::true_type()) has_add_check(check_first); - typedef decltype(has_add_check(check_first())) has_add; + using has_add = decltype(has_add_check(check_first())); 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)std::declval().last(), std::true_type()) has_last_check(check_first); - typedef decltype(has_last_check(check_first())) has_last; + using has_last = decltype(has_last_check(check_first())); static_assert(has_last::value, "PartsContainer doesn't provide last() method"); @@ -481,8 +472,8 @@ struct parts_container_concept_check : std::true_type { 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; + using has_substitute_last = + decltype(has_substitute_last_check(check_first())); static_assert(has_substitute_last::value, "PartsContainer doesn't provide substitute_last() method"); @@ -490,7 +481,7 @@ struct parts_container_concept_check : std::true_type { template static decltype((void)std::declval().begin(), std::true_type()) has_begin_check(check_first); - typedef decltype(has_begin_check(check_first())) has_begin; + using has_begin = decltype(has_begin_check(check_first())); static_assert(has_begin::value, "PartsContainer doesn't provide begin() method"); @@ -498,32 +489,31 @@ struct parts_container_concept_check : std::true_type { template static decltype((void)std::declval().end(), std::true_type()) has_end_check(check_first); - typedef decltype(has_end_check(check_first())) has_end; + using has_end = decltype(has_end_check(check_first())); static_assert(has_end::value, "PartsContainer doesn't provide end() method"); }; template struct parts_provider_type { - typedef compiletime_parts_provider< - Format, typename compiletime_prepared_parts_type_provider::type> - type; + using type = compiletime_parts_provider< + Format, typename compiletime_prepared_parts_type_provider::type>; }; template struct parts_provider_type { static_assert(parts_container_concept_check::value, "Parts container doesn't meet the concept"); - typedef runtime_parts_provider type; + using type = runtime_parts_provider; }; template struct basic_prepared_format { - typedef internal::prepared_format::value, - Format, PreparedPartsContainer>::type, - Args...> - type; + using type = + internal::prepared_format::value, Format, + PreparedPartsContainer>::type, + Args...>; }; template @@ -539,7 +529,7 @@ std::basic_string to_runtime_format(const Char* format) { template >> class parts_container { public: - typedef format_part format_part_type; + using format_part_type = format_part; void add(format_part_type part) { parts_.push_back(std::move(part)); } @@ -572,9 +562,9 @@ class parts_container { // Delegate preparing to preparator, to take advantage of a partial // specialization. template struct preparator { - typedef parts_container> container; - typedef typename basic_prepared_format::type - prepared_format_type; + using container = parts_container>; + using prepared_format_type = + typename basic_prepared_format::type; static auto prepare(Format format) -> prepared_format_type { return prepared_format_type(std::move(format)); @@ -585,8 +575,8 @@ template struct preparator> { - typedef prepared_format - prepared_format_type; + using prepared_format_type = + prepared_format; static auto prepare(PassedFormat format) -> prepared_format_type { return prepared_format_type(std::move(format));