mirror of
https://github.com/fmtlib/fmt.git
synced 2025-02-26 09:40:54 +00:00
Reduce syntactic noise
This commit is contained in:
parent
48e6dcd0f2
commit
d66fa2216e
@ -861,7 +861,7 @@ class arg_map {
|
|||||||
if (it->name == name)
|
if (it->name == name)
|
||||||
return it->arg;
|
return it->arg;
|
||||||
}
|
}
|
||||||
return basic_format_arg<Context>();
|
return {};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -899,9 +899,8 @@ class context_base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
basic_parse_context<char_type> &parse_context() {
|
basic_parse_context<char_type> &parse_context() { return parse_context_; }
|
||||||
return parse_context_;
|
basic_format_args<Context> args() const { return args_; }
|
||||||
}
|
|
||||||
|
|
||||||
internal::error_handler error_handler() {
|
internal::error_handler error_handler() {
|
||||||
return parse_context_.error_handler();
|
return parse_context_.error_handler();
|
||||||
@ -915,8 +914,6 @@ class context_base {
|
|||||||
|
|
||||||
// Advances the begin iterator to ``it``.
|
// Advances the begin iterator to ``it``.
|
||||||
void advance_to(iterator it) { out_ = it; }
|
void advance_to(iterator it) { out_ = it; }
|
||||||
|
|
||||||
basic_format_args<Context> args() const { return args_; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extracts a reference to the container from back_insert_iterator.
|
// Extracts a reference to the container from back_insert_iterator.
|
||||||
@ -1086,15 +1083,11 @@ const long long format_arg_store<Context, Args...>::TYPES = get_types();
|
|||||||
*/
|
*/
|
||||||
template <typename Context, typename ...Args>
|
template <typename Context, typename ...Args>
|
||||||
inline format_arg_store<Context, Args...>
|
inline format_arg_store<Context, Args...>
|
||||||
make_format_args(const Args &... args) {
|
make_format_args(const Args &... args) { return {args...}; }
|
||||||
return format_arg_store<Context, Args...>(args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename ...Args>
|
template <typename ...Args>
|
||||||
inline format_arg_store<format_context, Args...>
|
inline format_arg_store<format_context, Args...>
|
||||||
make_format_args(const Args &... args) {
|
make_format_args(const Args &... args) { return {args...}; }
|
||||||
return format_arg_store<format_context, Args...>(args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Formatting arguments. */
|
/** Formatting arguments. */
|
||||||
template <typename Context>
|
template <typename Context>
|
||||||
@ -1240,12 +1233,12 @@ struct named_arg : named_arg_base<Char> {
|
|||||||
*/
|
*/
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline internal::named_arg<T, char> arg(string_view name, const T &arg) {
|
inline internal::named_arg<T, char> arg(string_view name, const T &arg) {
|
||||||
return internal::named_arg<T, char>(name, arg);
|
return {name, arg};
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline internal::named_arg<T, wchar_t> arg(wstring_view name, const T &arg) {
|
inline internal::named_arg<T, wchar_t> arg(wstring_view name, const T &arg) {
|
||||||
return internal::named_arg<T, wchar_t>(name, arg);
|
return {name, arg};
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function template is deleted intentionally to disable nested named
|
// This function template is deleted intentionally to disable nested named
|
||||||
|
@ -434,31 +434,26 @@ void basic_buffer<T>::append(const U *begin, const U *end) {
|
|||||||
// A UTF-8 code unit type.
|
// A UTF-8 code unit type.
|
||||||
struct char8_t {
|
struct char8_t {
|
||||||
char value;
|
char value;
|
||||||
FMT_CONSTEXPR explicit operator bool() const FMT_NOEXCEPT {
|
FMT_CONSTEXPR FMT_EXPLICIT operator bool() const FMT_NOEXCEPT {
|
||||||
return value != 0;
|
return value != 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// A UTF-8 string view.
|
// A UTF-8 string view.
|
||||||
class u8string_view : public basic_string_view<char8_t> {
|
class u8string_view : public basic_string_view<char8_t> {
|
||||||
private:
|
|
||||||
typedef basic_string_view<char8_t> base;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using basic_string_view::basic_string_view;
|
typedef char8_t char_type;
|
||||||
using basic_string_view::char_type;
|
|
||||||
|
|
||||||
u8string_view(const char *s)
|
u8string_view(const char *s):
|
||||||
: base(reinterpret_cast<const char8_t*>(s)) {}
|
basic_string_view<char8_t>(reinterpret_cast<const char8_t*>(s)) {}
|
||||||
|
u8string_view(const char *s, size_t count) FMT_NOEXCEPT:
|
||||||
u8string_view(const char *s, size_t count) FMT_NOEXCEPT
|
basic_string_view<char8_t>(reinterpret_cast<const char8_t*>(s), count) {}
|
||||||
: base(reinterpret_cast<const char8_t*>(s), count) {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if FMT_USE_USER_DEFINED_LITERALS
|
#if FMT_USE_USER_DEFINED_LITERALS
|
||||||
inline namespace literals {
|
inline namespace literals {
|
||||||
inline u8string_view operator"" _u(const char *s, std::size_t n) {
|
inline u8string_view operator"" _u(const char *s, std::size_t n) {
|
||||||
return u8string_view(s, n);
|
return {s, n};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user