Skip to content

Commit

Permalink
Allowing formatting non-copyable ranges. (#3290)
Browse files Browse the repository at this point in the history
  • Loading branch information
brevzin committed Jan 27, 2023
1 parent 70db193 commit 05e3a92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion include/fmt/ranges.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ template <typename T>
struct has_mutable_begin_end<
T, void_t<decltype(detail::range_begin(std::declval<T>())),
decltype(detail::range_end(std::declval<T>())),
enable_if_t<std::is_copy_constructible<T>::value>>>
// the extra int here is because older versions of MSVC don't
// SFINAE properly unless there are distinct types
int>>
: std::true_type {};

template <typename T>
Expand Down
6 changes: 3 additions & 3 deletions test/ranges-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ template <typename T> class noncopyable_range {
std::vector<T> vec;

public:
using const_iterator = typename ::std::vector<T>::const_iterator;
using iterator = typename ::std::vector<T>::iterator;

template <typename... Args>
explicit noncopyable_range(Args&&... args)
Expand All @@ -202,8 +202,8 @@ template <typename T> class noncopyable_range {
noncopyable_range(noncopyable_range const&) = delete;
noncopyable_range(noncopyable_range&) = delete;

const_iterator begin() const { return vec.begin(); }
const_iterator end() const { return vec.end(); }
iterator begin() { return vec.begin(); }
iterator end() { return vec.end(); }
};

TEST(ranges_test, range) {
Expand Down

0 comments on commit 05e3a92

Please sign in to comment.