Applied clang-format (possibly correctly)

This commit is contained in:
Barry Revzin 2021-10-16 11:52:31 -05:00
parent c0984ebc45
commit 562719df5f
2 changed files with 19 additions and 13 deletions

View File

@ -2749,11 +2749,11 @@ template <typename It, typename Sentinel, typename Char>
struct formatter<join_view<It, Sentinel, Char>, Char> {
private:
using value_type =
#ifdef __cpp_lib_ranges
std::iter_value_t<It>;
#else
typename std::iterator_traits<It>::value_type;
#endif
#ifdef __cpp_lib_ranges
std::iter_value_t<It>;
#else
typename std::iterator_traits<It>::value_type;
#endif
using context = buffer_context<Char>;
using mapper = detail::arg_mapper<context>;

View File

@ -258,7 +258,7 @@ struct zstring {
zstring_sentinel end() const { return {}; }
};
#ifdef __cpp_lib_ranges
# ifdef __cpp_lib_ranges
struct cpp20_only_range {
struct iterator {
int val = 0;
@ -268,9 +268,12 @@ struct cpp20_only_range {
using iterator_concept = std::input_iterator_tag;
iterator() = default;
iterator(int i) : val(i) { }
iterator(int i) : val(i) {}
int operator*() const { return val; }
iterator& operator++() { ++val; return *this; }
iterator& operator++() {
++val;
return *this;
}
void operator++(int) { ++*this; }
bool operator==(const iterator& rhs) const { return val == rhs.val; }
};
@ -283,7 +286,7 @@ struct cpp20_only_range {
};
static_assert(std::input_iterator<cpp20_only_range::iterator>);
#endif
# endif
TEST(ranges_test, join_sentinel) {
auto hello = zstring{"hello"};
@ -310,10 +313,13 @@ TEST(ranges_test, join_range) {
const auto z = std::vector<int>(3u, 0);
EXPECT_EQ(fmt::format("{}", fmt::join(z, ",")), "0,0,0");
#ifdef __cpp_lib_ranges
EXPECT_EQ(fmt::format("{}", cpp20_only_range{.lo=0, .hi=5}), "[0, 1, 2, 3, 4]");
EXPECT_EQ(fmt::format("{}", fmt::join(cpp20_only_range{.lo=0, .hi=5}, ",")), "0,1,2,3,4");
#endif
# ifdef __cpp_lib_ranges
EXPECT_EQ(fmt::format("{}", cpp20_only_range{.lo = 0, .hi = 5}),
"[0, 1, 2, 3, 4]");
EXPECT_EQ(
fmt::format("{}", fmt::join(cpp20_only_range{.lo = 0, .hi = 5}, ",")),
"0,1,2,3,4");
# endif
}
#endif // FMT_RANGES_TEST_ENABLE_JOIN