Skip to content

Commit

Permalink
Adapt minimal boilerplate
Browse files Browse the repository at this point in the history
I would agree with fmtlib/fmt#2086 on that.
  • Loading branch information
emmanuelthome committed Jan 17, 2023
1 parent 0882eaf commit 6f177ae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions linalg/bwc/lingen_call_companion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ inline std::istream& operator>>(std::istream& is, lingen_call_companion::key & c

namespace fmt {
template <> struct /* fmt:: */ formatter<lingen_call_companion::key>: formatter<string_view> {
// only allow {} for formatting. No :, no :x, etc. It could be nice
// to allow them, though. Note that this should be constexpr with
// c++-14 or later
auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); }
template <typename FormatContext>
auto format(lingen_call_companion::key const & c, FormatContext& ctx) -> decltype(ctx.out()) {
std::ostringstream os;
Expand Down
8 changes: 8 additions & 0 deletions tests/sieve/test_fb_root.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ std::ostream& operator<<(std::ostream& os, fb_root_p1_t<T> const & R)
*/
namespace fmt {
template <typename T> struct /* fmt:: */ formatter<fb_root_p1_t<T>>: formatter<string_view> {
// only allow {} for formatting. No :, no :x, etc. It could be nice
// to allow them, though. Note that this should be constexpr with
// c++-14 or later
auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); }
template <typename FormatContext>
auto format(fb_root_p1_t<T> const & c, FormatContext& ctx) -> decltype(ctx.out()) {
std::ostringstream os;
Expand All @@ -63,6 +67,10 @@ template <typename T> struct /* fmt:: */ formatter<fb_root_p1_t<T>>: formatter<s
};

template <> struct /* fmt:: */ formatter<qlattice_basis>: formatter<string_view> {
// only allow {} for formatting. No :, no :x, etc. It could be nice
// to allow them, though. Note that this should be constexpr with
// c++-14 or later
auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); }
template <typename FormatContext>
auto format(qlattice_basis const & c, FormatContext& ctx) -> decltype(ctx.out()) {
std::ostringstream os;
Expand Down
4 changes: 4 additions & 0 deletions utils/cxx_mpz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ inline std::istream& operator>>(std::istream& is, cxx_mpq & x) { return is >> (m

namespace fmt {
template <> struct /* fmt:: */ formatter<cxx_mpz>: formatter<string_view> {
// only allow {} for formatting. No :, no :x, etc. It could be nice
// to allow them, though. Note that this should be constexpr with
// c++-14 or later
auto parse(format_parse_context& ctx) -> decltype(ctx.begin()) { return ctx.begin(); }
template <typename FormatContext>
auto format(cxx_mpz const & c, FormatContext& ctx) -> decltype(ctx.out()) {
std::ostringstream os;
Expand Down

0 comments on commit 6f177ae

Please sign in to comment.