1#ifndef XPED_FMT_HELPERS_HPP_
2#define XPED_FMT_HELPERS_HPP_
5#include "fmt/ostream.h"
13template <
typename T,
typename Char>
14struct fmt::formatter<std::complex<T>, Char> :
public fmt::formatter<T, Char>
16 typedef fmt::formatter<T, Char> base;
23 fmt::detail::dynamic_format_specs<Char> specs_;
24 FMT_CONSTEXPR
auto parse(format_parse_context& ctx) ->
decltype(ctx.begin())
26 auto it = ctx.begin();
44 auto type = fmt::detail::type_constant<T, Char>::value;
45 parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx, type);
47 return base::parse(ctx);
49 template <
typename FormatCtx>
50 auto format(
const std::complex<T>& x, FormatCtx& ctx)
const ->
decltype(ctx.out())
52 format_to(ctx.out(),
"(");
53 if(style_ == style::pair) {
54 base::format(x.real(), ctx);
55 format_to(ctx.out(),
",");
56 base::format(x.imag(), ctx);
57 return format_to(ctx.out(),
")");
59 if(x.real() || !x.imag()) base::format(x.real(), ctx);
61 if(x.real() && x.imag() >= 0 && specs_.sign != sign::plus) format_to(ctx.out(),
"+");
62 base::format(x.imag(), ctx);
63 if(style_ == style::star)
64 format_to(ctx.out(),
"*i");
66 format_to(ctx.out(),
"i");
67 if(std::is_same<
typename std::decay<T>::type,
float>::value) format_to(ctx.out(),
"f");
68 if(std::is_same<
typename std::decay<T>::type,
long double>::value) format_to(ctx.out(),
"l");
70 return format_to(ctx.out(),
")");
std::string format(qarray< Symmetry::Nq > qnum)
Definition: functions.hpp:53