forked from fmtlib/fmt
Get rid of the FILE* hack and reword apidocs
This commit is contained in:
@ -200,6 +200,8 @@ The following user-defined literals are defined in ``fmt/format.h``.
|
|||||||
Utilities
|
Utilities
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
.. doxygenclass:: fmt::is_char
|
||||||
|
|
||||||
.. doxygentypedef:: fmt::char_t
|
.. doxygentypedef:: fmt::char_t
|
||||||
|
|
||||||
.. doxygenfunction:: fmt::formatted_size(string_view, const Args&...)
|
.. doxygenfunction:: fmt::formatted_size(string_view, const Args&...)
|
||||||
|
@ -518,13 +518,6 @@ inline void reset_color(basic_memory_buffer<Char>& buffer) FMT_NOEXCEPT {
|
|||||||
buffer.append(begin, end);
|
buffer.append(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The following specialization disables using std::FILE as a character type,
|
|
||||||
// which is needed because or else
|
|
||||||
// fmt::print(stderr, fmt::emphasis::bold, "");
|
|
||||||
// would take stderr (a std::FILE *) as the format string.
|
|
||||||
template <> struct is_string<std::FILE*> : std::false_type {};
|
|
||||||
template <> struct is_string<const std::FILE*> : std::false_type {};
|
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
std::basic_string<Char> vformat(const text_style& ts,
|
std::basic_string<Char> vformat(const text_style& ts,
|
||||||
basic_string_view<Char> format_str,
|
basic_string_view<Char> format_str,
|
||||||
|
@ -442,33 +442,25 @@ template <typename Char> class basic_string_view {
|
|||||||
using string_view = basic_string_view<char>;
|
using string_view = basic_string_view<char>;
|
||||||
using wstring_view = basic_string_view<wchar_t>;
|
using wstring_view = basic_string_view<wchar_t>;
|
||||||
|
|
||||||
|
/** Specifies if ``T`` is a character type. Can be specialized by users. */
|
||||||
|
template <typename T> struct is_char : std::is_integral<T> {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\rst
|
\rst
|
||||||
The function ``to_string_view`` adapts non-intrusively any kind of string or
|
Returns a string view of `s`. In order to add custom string type support to
|
||||||
string-like type if the user provides a (possibly templated) overload of
|
{fmt} provide an overload of `to_string_view` for it in the same namespace as
|
||||||
``to_string_view`` which takes an instance of the string class
|
the type for the argument-dependent lookup to work.
|
||||||
``StringType<Char>`` and returns a ``fmt::basic_string_view<Char>``.
|
|
||||||
The conversion function must live in the very same namespace as
|
|
||||||
``StringType<Char>`` to be picked up by ADL. Non-templated string types
|
|
||||||
like f.e. QString must return a ``basic_string_view`` with a fixed matching
|
|
||||||
char type.
|
|
||||||
|
|
||||||
**Example**::
|
**Example**::
|
||||||
|
|
||||||
namespace my_ns {
|
namespace my_ns {
|
||||||
inline string_view to_string_view(const my_string &s) {
|
inline string_view to_string_view(const my_string& s) {
|
||||||
return {s.data(), s.length()};
|
return {s.data(), s.length()};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string message = fmt::format(my_string("The answer is {}"), 42);
|
std::string message = fmt::format(my_string("The answer is {}"), 42);
|
||||||
\endrst
|
\endrst
|
||||||
*/
|
*/
|
||||||
template <typename Char>
|
|
||||||
inline basic_string_view<Char> to_string_view(basic_string_view<Char> s) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Char, typename Traits, typename Allocator>
|
template <typename Char, typename Traits, typename Allocator>
|
||||||
inline basic_string_view<Char> to_string_view(
|
inline basic_string_view<Char> to_string_view(
|
||||||
const std::basic_string<Char, Traits, Allocator>& s) {
|
const std::basic_string<Char, Traits, Allocator>& s) {
|
||||||
@ -476,6 +468,11 @@ inline basic_string_view<Char> to_string_view(
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename Char>
|
template <typename Char>
|
||||||
|
inline basic_string_view<Char> to_string_view(basic_string_view<Char> s) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename Char, FMT_ENABLE_IF(is_char<Char>::value)>
|
||||||
inline basic_string_view<Char> to_string_view(const Char* s) {
|
inline basic_string_view<Char> to_string_view(const Char* s) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -597,10 +594,6 @@ struct is_string
|
|||||||
!std::is_same<dummy_string_view,
|
!std::is_same<dummy_string_view,
|
||||||
decltype(to_string_view(std::declval<S>()))>::value> {};
|
decltype(to_string_view(std::declval<S>()))>::value> {};
|
||||||
|
|
||||||
// Forward declare FILE* specialization defined in color.h
|
|
||||||
template <> struct is_string<std::FILE*>;
|
|
||||||
template <> struct is_string<const std::FILE*>;
|
|
||||||
|
|
||||||
template <typename S> struct char_t_impl {
|
template <typename S> struct char_t_impl {
|
||||||
typedef decltype(to_string_view(std::declval<S>())) result;
|
typedef decltype(to_string_view(std::declval<S>())) result;
|
||||||
typedef typename result::char_type type;
|
typedef typename result::char_type type;
|
||||||
|
Reference in New Issue
Block a user