is_format_string -> is_string

This commit is contained in:
Victor Zverovich 2018-10-07 07:48:27 -07:00
parent fea712abb1
commit 655ce53383
5 changed files with 37 additions and 26 deletions

View File

@ -183,7 +183,7 @@ output ``operator<<`` when one is defined for a user-defined type.
Output iterator support
-----------------------
.. doxygenfunction:: fmt::format_to(OutputIt, const String&, const Args&...)
.. doxygenfunction:: fmt::format_to(OutputIt, const S&, const Args&...)
.. doxygenfunction:: fmt::format_to_n(OutputIt, std::size_t, string_view, const Args&...)
.. doxygenstruct:: fmt::format_to_n_result
:members:
@ -200,6 +200,8 @@ The following user-defined literals are defined in ``fmt/format.h``.
Utilities
---------
.. doxygentypedef:: fmt::char_t
.. doxygenfunction:: fmt::formatted_size(string_view, const Args&...)
.. doxygenfunction:: fmt::to_string(const T&)

View File

@ -89,11 +89,11 @@ def build_docs(version='dev', **kwargs):
FMT_USE_VARIADIC_TEMPLATES=1 \
FMT_USE_RVALUE_REFERENCES=1 \
FMT_USE_USER_DEFINED_LITERALS=1 \
FMT_USE_ALIAS_TEMPLATES=1 \
FMT_API= \
"FMT_BEGIN_NAMESPACE=namespace fmt {{" \
"FMT_END_NAMESPACE=}}" \
"FMT_STRING_ALIAS=1" \
"FMT_CHAR(S)=char_t<S>"
"FMT_STRING_ALIAS=1"
EXCLUDE_SYMBOLS = fmt::internal::* StringValue write_str
'''.format(include_dir, doxyxml_dir).encode('UTF-8'))
if p.returncode != 0:

View File

@ -296,7 +296,7 @@ void vprint_rgb(rgb fd, rgb bg, const String &format,
fmt::print(fmt::color::red, "Elapsed time: {0:.2f} seconds", 1.23);
*/
template <typename String, typename... Args>
typename std::enable_if<internal::is_format_string<String>::value>::type
typename std::enable_if<internal::is_string<String>::value>::type
print(rgb fd, const String &format_str, const Args & ... args) {
internal::check_format_string<Args...>(format_str);
typedef typename internal::format_string_traits<String>::char_type char_t;
@ -313,7 +313,7 @@ print(rgb fd, const String &format_str, const Args & ... args) {
"Elapsed time: {0:.2f} seconds", 1.23);
*/
template <typename String, typename... Args>
typename std::enable_if<internal::is_format_string<String>::value>::type
typename std::enable_if<internal::is_string<String>::value>::type
print(rgb fd, rgb bg, const String &format_str, const Args & ... args) {
internal::check_format_string<Args...>(format_str);
typedef typename internal::format_string_traits<String>::char_type char_t;

View File

@ -500,7 +500,7 @@ struct format_string_traits<
format_string_traits_base<typename S::char_type> {};
template <typename S>
struct is_format_string : std::is_empty<format_string_traits<S>> {};
struct is_string : std::is_empty<format_string_traits<S>> {};
template <typename S>
struct is_compile_string : std::is_base_of<compile_string, S> {};
@ -1233,7 +1233,7 @@ class basic_format_args {
/** An alias to ``basic_format_args<context>``. */
// It is a separate type rather than a typedef to make symbols readable.
struct format_args: basic_format_args<format_context> {
struct format_args : basic_format_args<format_context> {
template <typename ...Args>
format_args(Args &&... arg)
: basic_format_args<format_context>(std::forward<Args>(arg)...) {}
@ -1244,12 +1244,23 @@ struct wformat_args : basic_format_args<wformat_context> {
: basic_format_args<wformat_context>(std::forward<Args>(arg)...) {}
};
#if FMT_HAS_FEATURE(cxx_alias_templates)
#ifndef FMT_USE_ALIAS_TEMPLATES
# define FMT_USE_ALIAS_TEMPLATES FMT_HAS_FEATURE(cxx_alias_templates)
#endif
#if FMT_USE_ALIAS_TEMPLATES
/** String's character type. */
template <typename S>
using char_t = typename internal::format_string_traits<S>::char_type;
#define FMT_CHAR(S) char_t<S>
template <typename S, typename T>
using enable_if_string_t =
typename std::enable_if<internal::is_string<S>::value, T>::type;
#define FMT_ENABLE_IF_STRING(S, T) enable_if_string_t<S, T>
#else
#define FMT_CHAR(S) typename internal::format_string_traits<S>::char_type
#define FMT_ENABLE_IF_STRING(S, T) \
typename std::enable_if<internal::is_string<S>::value, T>::type
#endif
namespace internal {
@ -1258,7 +1269,8 @@ struct named_arg_base {
basic_string_view<Char> name;
// Serialized value<context>.
mutable char data[sizeof(basic_format_arg<typename buffer_context<Char>::type>)];
mutable char data[
sizeof(basic_format_arg<typename buffer_context<Char>::type>)];
named_arg_base(basic_string_view<Char> nm) : name(nm) {}
@ -1362,7 +1374,7 @@ typename std::enable_if<
template <typename Container, typename S, typename... Args>
inline typename std::enable_if<
is_contiguous<Container>::value && internal::is_format_string<S>::value,
is_contiguous<Container>::value && internal::is_string<S>::value,
std::back_insert_iterator<Container>>::type
format_to(std::back_insert_iterator<Container> out, const S &format_str,
const Args &... args) {
@ -1410,7 +1422,7 @@ FMT_API void vprint(std::FILE *f, wstring_view format_str, wformat_args args);
\endrst
*/
template <typename S, typename... Args>
inline typename std::enable_if<internal::is_format_string<S>::value>::type
inline FMT_ENABLE_IF_STRING(S, void)
print(std::FILE *f, const S &format_str, const Args &... args) {
vprint(f, internal::to_string_view(format_str),
internal::checked_args<S, Args...>(format_str, args...));
@ -1429,7 +1441,7 @@ FMT_API void vprint(wstring_view format_str, wformat_args args);
\endrst
*/
template <typename S, typename... Args>
inline typename std::enable_if<internal::is_format_string<S>::value>::type
inline FMT_ENABLE_IF_STRING(S, void)
print(const S &format_str, const Args &... args) {
vprint(internal::to_string_view(format_str),
internal::checked_args<S, Args...>(format_str, args...));

View File

@ -3530,14 +3530,13 @@ inline OutputIt vformat_to(
fmt::format_to(std::back_inserter(out), "{}", 42);
\endrst
*/
template <typename OutputIt, typename String, typename... Args>
inline typename std::enable_if<
internal::is_format_string<String>::value, OutputIt>::type
format_to(OutputIt out, const String &format_str, const Args &... args) {
template <typename OutputIt, typename S, typename... Args>
inline FMT_ENABLE_IF_STRING(S, OutputIt)
format_to(OutputIt out, const S &format_str, const Args &... args) {
internal::check_format_string<Args...>(format_str);
typedef typename format_context_t<OutputIt, FMT_CHAR(String)>::type context;
typedef typename format_context_t<OutputIt, FMT_CHAR(S)>::type context;
format_arg_store<context, Args...> as{args...};
return vformat_to(out, basic_string_view<FMT_CHAR(String)>(format_str),
return vformat_to(out, basic_string_view<FMT_CHAR(S)>(format_str),
basic_format_args<context>(as));
}
@ -3580,15 +3579,13 @@ inline format_to_n_result<OutputIt> vformat_to_n(
end of the output range.
\endrst
*/
template <typename OutputIt, typename String, typename... Args>
inline typename std::enable_if<
internal::is_format_string<String>::value,
format_to_n_result<OutputIt>>::type format_to_n(
OutputIt out, std::size_t n, const String &format_str,
const Args &... args) {
template <typename OutputIt, typename S, typename... Args>
inline FMT_ENABLE_IF_STRING(S, format_to_n_result<OutputIt>)
format_to_n(OutputIt out, std::size_t n, const S &format_str,
const Args &... args) {
internal::check_format_string<Args...>(format_str);
typedef FMT_CHAR(String) Char;
format_arg_store<format_to_n_context<OutputIt, Char>, Args...> as{ args... };
typedef FMT_CHAR(S) Char;
format_arg_store<format_to_n_context<OutputIt, Char>, Args...> as(args...);
return vformat_to_n(out, n, internal::to_string_view(format_str),
format_to_n_args<OutputIt, Char>(as));
}