Allowing formatting non-copyable ranges. (#3290)

This commit is contained in:
Barry Revzin 2023-01-27 14:29:57 -06:00 committed by GitHub
parent 70db193f09
commit 05e3a9233a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -155,7 +155,9 @@ template <typename T>
struct has_mutable_begin_end< struct has_mutable_begin_end<
T, void_t<decltype(detail::range_begin(std::declval<T>())), T, void_t<decltype(detail::range_begin(std::declval<T>())),
decltype(detail::range_end(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 {}; : std::true_type {};
template <typename T> template <typename T>

View File

@ -193,7 +193,7 @@ template <typename T> class noncopyable_range {
std::vector<T> vec; std::vector<T> vec;
public: public:
using const_iterator = typename ::std::vector<T>::const_iterator; using iterator = typename ::std::vector<T>::iterator;
template <typename... Args> template <typename... Args>
explicit noncopyable_range(Args&&... args) explicit noncopyable_range(Args&&... args)
@ -202,8 +202,8 @@ template <typename T> class noncopyable_range {
noncopyable_range(noncopyable_range const&) = delete; noncopyable_range(noncopyable_range const&) = delete;
noncopyable_range(noncopyable_range&) = delete; noncopyable_range(noncopyable_range&) = delete;
const_iterator begin() const { return vec.begin(); } iterator begin() { return vec.begin(); }
const_iterator end() const { return vec.end(); } iterator end() { return vec.end(); }
}; };
TEST(ranges_test, range) { TEST(ranges_test, range) {