util/DereferenceIterator: use *declval() to guess the default value type

This allows the iterator to point to another iterator.
This commit is contained in:
Max Kellermann 2023-11-05 00:24:25 +01:00 committed by Max Kellermann
parent 5ab2c31500
commit edfa329e64
1 changed files with 2 additions and 5 deletions

View File

@ -1,8 +1,7 @@
// SPDX-License-Identifier: BSD-2-Clause
// author: Max Kellermann <max.kellermann@gmail.com>
#ifndef DEREFERENCE_ITERATOR_HXX
#define DEREFERENCE_ITERATOR_HXX
#pragma once
#include <iterator>
#include <type_traits>
@ -12,7 +11,7 @@
* original iterator.
*/
template<typename IT,
typename VT=typename std::remove_pointer<typename IT::value_type>::type>
typename VT=std::remove_reference_t<decltype(*std::declval<typename std::iterator_traits<IT>::value_type>())>>
class DereferenceIterator {
using Traits = std::iterator_traits<IT>;
@ -86,5 +85,3 @@ public:
return original != other.original;
}
};
#endif