util/DereferenceIterator: use *declval() to guess the default value type
This allows the iterator to point to another iterator.
This commit is contained in:
parent
5ab2c31500
commit
edfa329e64
@ -1,8 +1,7 @@
|
|||||||
// SPDX-License-Identifier: BSD-2-Clause
|
// SPDX-License-Identifier: BSD-2-Clause
|
||||||
// author: Max Kellermann <max.kellermann@gmail.com>
|
// author: Max Kellermann <max.kellermann@gmail.com>
|
||||||
|
|
||||||
#ifndef DEREFERENCE_ITERATOR_HXX
|
#pragma once
|
||||||
#define DEREFERENCE_ITERATOR_HXX
|
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
@ -12,7 +11,7 @@
|
|||||||
* original iterator.
|
* original iterator.
|
||||||
*/
|
*/
|
||||||
template<typename IT,
|
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 {
|
class DereferenceIterator {
|
||||||
using Traits = std::iterator_traits<IT>;
|
using Traits = std::iterator_traits<IT>;
|
||||||
|
|
||||||
@ -86,5 +85,3 @@ public:
|
|||||||
return original != other.original;
|
return original != other.original;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
|
Loading…
Reference in New Issue
Block a user