iterator-traits Questions
2
Solved
In an algorithm, I can determine the value_type directly from the iterator via iter::value_type. Why do algorithms use iterator_traits to do the same?
#include <iostream>
#include <v...
Weinstock asked 14/6, 2023 at 8:1
0
I have a trouble with using std::views::filter on joined streams/ranges. I don't know what's exactly wrong here. I suppose the elements may not be passed with the proper (copy/move) semantics, refe...
Shade asked 31/10, 2021 at 16:9
1
Solved
C++20 brings a more powerful iterator system, one of them is to introduce iterator_concept on the basis of iterator_category.
I found that the iterator_concept and iterator_category of many iterato...
Allier asked 19/5, 2021 at 15:46
3
Solved
I'm doing this:
const int arr[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 };
const auto foo = cbegin(arr);
const typename iterator_traits<decltype(foo)>::value_type bar = 1;
I would ha...
Beliabelial asked 9/1, 2019 at 15:23
3
Solved
I see that iterator_traits always defines a difference_type: https://en.cppreference.com/w/cpp/iterator/iterator_traits#Member_types
I'm just wondering why, wouldn't that be ptrdiff_t for every ty...
Ibbie asked 17/9, 2018 at 15:55
1
Solved
C++17 introduced the concept of ContiguousIterator http://en.cppreference.com/w/cpp/iterator.
However it doesn't seem that there are plans to have a contiguous_iterator_tag (in the same way we now ...
Chuipek asked 17/3, 2017 at 7:47
2
Solved
It appears that the iterator adaptor reverse_iterator doubly defines most of its nested types. In particular, it inherits publicly from std::iterator which exposes iterator_category, value_type, di...
Kirima asked 17/3, 2015 at 20:21
4
Solved
I'd like to specialize std::iterator_traits<> for iterators of a container class template that does not have the usual nested typedefs (like value_type, difference_type, etc.) and whose sourc...
Dyscrasia asked 28/10, 2011 at 9:58
4
In my project, I want to split stream into some given type of values, so I implement a template function as
template <typename TElem, typename TOutputIter>
TOutputIter SplitSpace(std::istrea...
Paraprofessional asked 23/4, 2013 at 9:23
1
Solved
How does one define forward-output-iterators in C++11 in a canonical way?
According to the standard a forward_iterator is only a input_iterator. So the corresponding forward_iterator_tag only exte...
Laveen asked 27/12, 2012 at 22:49
1
Solved
Are ForwardIterators required to be OutputIterators? My current STL-implementation (VS2012) derives forward_iterator_tag from both input_iterator_tag and output_iterator_tag, but I can't find this ...
Urata asked 27/12, 2012 at 17:25
2
Solved
In the C++ standard library, why is
std::iterator_traits<const T*>::value_type
the same type as
std::iterator_traits<T*>::value_type
Why it is designed like that? Shouldn't the first ...
Kitchenette asked 10/10, 2012 at 12:31
1
Solved
I am new to C++ so please bear with me. I am trying to understand STL iterator_traits. In the book "The C++ Standard Library" the structure iterator_traits is defined as follows:
template...
Ergotism asked 19/7, 2011 at 3:30
1
Solved
I have the following code:
template<typename T, typename Allocator = std::allocator<T> >
class Carray {
// ...
typedef T* pointer;
typedef pointer iterator;
// ...
};
Now I'm try...
Swap asked 18/6, 2011 at 21:9
1
© 2022 - 2024 — McMap. All rights reserved.