A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/fmtlib/fmt/commit/274ba2645bdae12f6f0c7d7ca24659c4af670548 below:

allow format_as() to format reference (#3739) · fmtlib/fmt@274ba26 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+9

-1

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+9

-1

lines changed Original file line number Diff line number Diff line change

@@ -1332,7 +1332,7 @@ using ulong_type = conditional_t<long_short, unsigned, unsigned long long>;

1332 1332

template <typename T> struct format_as_result {

1333 1333

template <typename U,

1334 1334

FMT_ENABLE_IF(std::is_enum<U>::value || std::is_class<U>::value)>

1335 -

static auto map(U*) -> decltype(format_as(std::declval<U>()));

1335 +

static auto map(U*) -> remove_cvref_t<decltype(format_as(std::declval<U>()))>;

1336 1336

static auto map(...) -> void;

1337 1337 1338 1338

using type = decltype(map(static_cast<T*>(nullptr)));

Original file line number Diff line number Diff line change

@@ -2173,13 +2173,21 @@ auto format_as(scoped_enum_as_string) -> std::string { return "foo"; }

2173 2173 2174 2174

struct struct_as_int {};

2175 2175

auto format_as(struct_as_int) -> int { return 42; }

2176 + 2177 +

struct struct_as_const_reference {

2178 +

const std::string name = "foo";

2179 +

};

2180 +

auto format_as(const struct_as_const_reference& s) -> const std::string& {

2181 +

return s.name;

2182 +

}

2176 2183

} // namespace test

2177 2184 2178 2185

TEST(format_test, format_as) {

2179 2186

EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_int()), "42");

2180 2187

EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_string_view()), "foo");

2181 2188

EXPECT_EQ(fmt::format("{}", test::scoped_enum_as_string()), "foo");

2182 2189

EXPECT_EQ(fmt::format("{}", test::struct_as_int()), "42");

2190 +

EXPECT_EQ(fmt::format("{}", test::struct_as_const_reference()), "foo");

2183 2191

}

2184 2192 2185 2193

TEST(format_test, format_as_to_string) {

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4