15 #include <type_traits>
21 #if FMT_HAS_INCLUDE(<version>)
25 #if FMT_CPLUSPLUS >= 201703L
26 # if FMT_HAS_INCLUDE(<filesystem>)
27 # include <filesystem>
29 # if FMT_HAS_INCLUDE(<variant>)
32 # if FMT_HAS_INCLUDE(<optional>)
38 #if FMT_HAS_INCLUDE(<cxxabi.h>) || defined(__GLIBCXX__)
42 # ifndef __GABIXX_CXXABI_H__
43 # define FMT_HAS_ABI_CXA_DEMANGLE
47 #ifdef __cpp_lib_filesystem
52 template <
typename Char>
55 write_escaped_string<Char>(std::back_inserter(quoted), p.string<Char>());
62 write_escaped_string<wchar_t>(std::back_inserter(
buf), p.native());
65 FMT_THROW(std::runtime_error(
"invalid utf16"));
69 inline void write_escaped_path<std::filesystem::path::value_type>(
72 write_escaped_string<std::filesystem::path::value_type>(
73 std::back_inserter(quoted), p.native());
79 template <
typename Char>
82 template <
typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) {
84 this->set_debug_format(
false);
87 template <
typename FormatContext>
89 typename FormatContext::iterator {
91 detail::write_escaped_path(quoted, p);
101 template <
typename Char>
105 #ifdef __cpp_lib_optional
108 template <
typename T,
typename Char>
121 -> decltype(u.set_debug_format(
set)) {
122 u.set_debug_format(
set);
129 template <
typename ParseContext>
FMT_CONSTEXPR auto parse(ParseContext& ctx) {
130 maybe_set_debug_format(underlying_,
true);
131 return underlying_.parse(ctx);
134 template <
typename FormatContext>
135 auto format(std::optional<T>
const& opt, FormatContext& ctx)
const
136 -> decltype(ctx.out()) {
137 if (!opt)
return detail::write<Char>(ctx.out(),
none);
139 auto out = ctx.out();
140 out = detail::write<Char>(out, optional);
142 out = underlying_.format(*opt, ctx);
147 #endif // __cpp_lib_optional
149 #ifdef __cpp_lib_variant
153 template <
typename ParseContext>
154 FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
158 template <
typename FormatContext>
159 auto format(
const std::monostate&, FormatContext& ctx)
const
160 -> decltype(ctx.out()) {
161 auto out = ctx.out();
162 out = detail::write<Char>(out,
"monostate");
169 template <
typename T>
170 using variant_index_sequence =
173 template <
typename>
struct is_variant_like_ : std::false_type {};
174 template <
typename... Types>
175 struct is_variant_like_<std::variant<Types...>> : std::true_type {};
178 template <
typename T,
typename C>
class is_variant_formattable_ {
179 template <std::size_t... Is>
180 static std::conjunction<
182 check(std::index_sequence<Is...>);
185 static constexpr
const bool value =
186 decltype(check(variant_index_sequence<T>{}))::
value;
189 template <
typename Char,
typename OutputIt,
typename T>
190 auto write_variant_alternative(OutputIt out,
const T&
v) -> OutputIt {
193 else if constexpr (std::is_same_v<T, Char>)
196 return
write<Char>(out, v);
200 template <typename T> struct is_variant_like {
204 template <
typename T,
typename C>
struct is_variant_formattable {
205 static constexpr
const bool value =
210 template <
typename Variant,
typename Char>
214 is_variant_like<Variant>, is_variant_formattable<Variant, Char>>>> {
215 template <
typename ParseContext>
216 FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
220 template <
typename FormatContext>
222 -> decltype(ctx.out()) {
223 auto out = ctx.out();
225 out = detail::write<Char>(out,
"variant(");
229 out = detail::write_variant_alternative<Char>(out,
v);
232 }
catch (
const std::bad_variant_access&) {
233 detail::write<Char>(out,
"valueless by exception");
240 #endif // __cpp_lib_variant
244 template <
typename Char>
struct formatter<std::error_code, Char> {
245 template <
typename ParseContext>
250 template <
typename FormatContext>
252 -> decltype(ctx.out()) {
253 auto out = ctx.out();
255 out = detail::write<Char>(out, Char(
':'));
256 out = detail::write<Char>(out, ec.value());
262 template <
typename T,
typename Char>
265 typename std::enable_if<std::is_base_of<std::exception, T>::value>
::type> {
267 bool with_typename_ =
false;
271 -> decltype(ctx.begin()) {
272 auto it = ctx.begin();
273 auto end = ctx.end();
274 if (it ==
end || *it ==
'}')
return it;
277 with_typename_ =
true;
282 template <
typename OutputIt>
286 auto out = ctx.out();
290 const std::type_info& ti =
typeid(ex);
291 #ifdef FMT_HAS_ABI_CXA_DEMANGLE
293 std::size_t
size = 0;
294 std::unique_ptr<char, decltype(&std::free)> demangled_name_ptr(
295 abi::__cxa_demangle(ti.name(),
nullptr, &
size, &status), &std::free);
298 if (demangled_name_ptr) {
299 demangled_name_view = demangled_name_ptr.get();
309 char*
begin = demangled_name_ptr.get();
310 char* to = begin + 5;
311 for (
char *from = to, *
end = begin + demangled_name_view.
size();
314 if (from[0] ==
'_' && from[1] ==
'_') {
315 char* next = from + 1;
316 while (next < end && *next !=
':') next++;
317 if (next[0] ==
':' && next[1] ==
':') {
330 #elif FMT_MSC_VERSION
334 else if (demangled_name_view.
starts_with(
"struct "))
340 out = detail::write<Char>(out, Char(
':'));
341 out = detail::write<Char>(out, Char(
' '));
typename std::enable_if< B, T >::type enable_if_t
Define Imath::enable_if_t to be std for C++14, equivalent for C++11.
GLenum GLuint GLenum GLsizei const GLchar * buf
GLsizei const GLfloat * value
GLsizei const GLchar *const * path
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
bool_constant<!std::is_base_of< detail::unformattable, decltype(detail::arg_mapper< buffer_context< Char >>().map(std::declval< T >()))>::value > is_formattable
#define FMT_END_NAMESPACE
basic_string_view< char > string_view
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< Char >
GLint GLint GLsizei GLint GLenum GLenum type
constexpr auto set(type rhs) -> int
GLint GLint GLsizei GLint GLenum format
FMT_CONSTEXPR void remove_prefix(size_t n) noexcept
constexpr auto size() const noexcept-> size_t
FMT_CONSTEXPR_CHAR_TRAITS bool starts_with(basic_string_view< Char > sv) const noexcept
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
#define FMT_BEGIN_NAMESPACE
#define FMT_MODULE_EXPORT
PcpNodeRef_ChildrenIterator begin(const PcpNodeRef::child_const_range &r)
Support for range-based for loops for PcpNodeRef children ranges.