在这个答案中,我们可以看到我们可以创建自己的< code >视图。我已经试过了:
template <typename Range>
struct squared_view : std::ranges::view_interface<squared_view<Range>> {
struct iterator;
constexpr squared_view() = default;
constexpr squared_view(Range t): t(t) { }
auto begin() const { return iterator(std::ranges::begin(t)); }
auto end() const { return iterator(std::ranges::end(t)); }
Range t;
};
template <typename Range>
struct squared_view<Range>::iterator {
using value_type = typename std::ranges::iterator_t<Range>::value_type;
constexpr iterator() = default;
constexpr iterator(std::ranges::iterator_t<Range> it): it_{it} { }
iterator& operator++() {
++it_;
return *this;
}
iterator operator++(int) {
const iterator current{*this};
++it_;
return current;
}
value_type operator*() const {
const auto value = *it_;
return value * value;
}
bool operator==(iterator const& rhs) const { return it_ == rhs.it_; }
private:
std::ranges::iterator_t<Range> it_;
};
template <std::ranges::range Range>
squared_view(Range&&) -> squared_view<std::ranges::views::all_t<Range>>;
struct squared_fn {
template <typename Rng>
auto operator()(Rng&& rng) const {
return squared_view{std::forward<Rng>(rng)};
}
template <typename Rng>
friend decltype(auto) operator|(Rng&& rng, squared_fn fun) {
return fun(std::forward<Rng>(rng));
}
};
constexpr squared_fn squared;
当我认为我成功了:
int main() {
std::vector<int> vec = {1, 2, 3};
auto rng = vec | squared;
for (const auto e : rng) {
std::cout << e << ' '; // prints 1 4 9
}
}
原来我其实失败了,因为< code>std::ranges::range
为了找出原因,我尝试使用std::ranges::begin(rng)
,这导致了几十行错误,或多或少可以归结为:
note: no operand of the disjunction is satisfied
requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp> || __adl_begin<_Tp>
这很奇怪,因为我确实提供了成员begin()
和end()</code>(除非<code>__member_begin
完整的错误消息如下所示:
C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp: In function 'int main()':
C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:72:27: error: no match for call to '(const std::ranges::__cust_access::_Begin) (squared_view<std::ranges::ref_view<std::vector<int> > >&)'
72 | std::ranges::begin(rng);
| ^
In file included from C:/msys64/mingw64/include/c++/10.1.0/string:54,
from C:/msys64/mingw64/include/c++/10.1.0/bits/locale_classes.h:40,
from C:/msys64/mingw64/include/c++/10.1.0/bits/ios_base.h:41,
from C:/msys64/mingw64/include/c++/10.1.0/ios:42,
from C:/msys64/mingw64/include/c++/10.1.0/ostream:38,
from C:/msys64/mingw64/include/c++/10.1.0/iostream:39,
from C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:1:
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:400:2: note: candidate: 'constexpr auto std::ranges::__cust_access::_Begin::operator()(_Tp&&) const [with _Tp = squared_view<std::ranges::ref_view<std::vector<int> > >&]'
400 | operator()(_Tp&& __t) const noexcept(_S_noexcept<_Tp>())
| ^~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:400:2: note: constraints not satisfied
C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp: In instantiation of 'constexpr auto std::ranges::__cust_access::_Begin::operator()(_Tp&&) const [with _Tp = squared_view<std::ranges::ref_view<std::vector<int> > >&]':
C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:72:27: required from here
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:400:2: required by the constraints of 'template<class _Tp> requires (__maybe_borrowed_range<_Tp>) && ((is_array_v<typename std::remove_reference<_Tp>::type>) || (__member_begin<_Tp>) || (__adl_begin<_Tp>)) constexpr auto std::ranges::__cust_access::_Begin::operator()(_Tp&&) const'
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:398:4: note: no operand of the disjunction is satisfied
397 | requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp>
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398 | || __adl_begin<_Tp>
| ^~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:397:11: note: the operand 'is_array_v<std::remove_reference_t<_Tp> >' is unsatisfied because
397 | requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398 | || __adl_begin<_Tp>
| ~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:400:2: required by the constraints of 'template<class _Tp> requires (__maybe_borrowed_range<_Tp>) && ((is_array_v<typename std::remove_reference<_Tp>::type>) || (__member_begin<_Tp>) || (__adl_begin<_Tp>)) constexpr auto std::ranges::__cust_access::_Begin::operator()(_Tp&&) const'
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:397:11: note: the expression 'is_array_v<typename std::remove_reference<_Tp>::type> [with _Tp = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >&; _Tp = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >&]' evaluated to 'false'
397 | requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:397:50: note: the operand '__member_begin<_Tp>' is unsatisfied because
397 | requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp>
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
398 | || __adl_begin<_Tp>
| ~~~~~~~~~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/c++/10.1.0/bits/stl_iterator_base_types.h:71,
from C:/msys64/mingw64/include/c++/10.1.0/bits/stl_algobase.h:65,
from C:/msys64/mingw64/include/c++/10.1.0/bits/char_traits.h:39,
from C:/msys64/mingw64/include/c++/10.1.0/ios:40,
from C:/msys64/mingw64/include/c++/10.1.0/ostream:38,
from C:/msys64/mingw64/include/c++/10.1.0/iostream:39,
from C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:1:
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:847:15: required for the satisfaction of '__member_begin<_Tp>' [with _Tp = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >&]
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:847:32: in requirements with '_Tp& __t' [with _Tp = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >&]
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:849:28: note: 'std::__detail::__decay_copy(__t.begin())' does not satisfy return-type-requirement, because
849 | { __detail::__decay_copy(__t.begin()) } -> input_or_output_iterator;
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:849:6: error: deduced expression type does not satisfy placeholder constraints
849 | { __detail::__decay_copy(__t.begin()) } -> input_or_output_iterator;
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:849:6: note: constraints not satisfied
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:507:13: required for the satisfaction of 'weakly_incrementable<_Iter>' [with _Iter = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >::iterator<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >]
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:522:13: required for the satisfaction of 'input_or_output_iterator<squared_view<std::ranges::ref_view<std::vector<int> > >::iterator>'
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:509:10: in requirements with '_Iter __i' [with _Tp = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >::iterator<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >; _Iter = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >::iterator<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >]
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:511:11: note: the required type 'std::iter_difference_t<_Iter>' is invalid, because
511 | typename iter_difference_t<_Iter>;
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h: In substitution of 'template<class _Tp> using __iter_diff_t = typename std::__detail::__iter_traits_impl<_Tp, std::incrementable_traits<_Iter> >::type::difference_type [with _Tp = squared_view<std::ranges::ref_view<std::vector<int> > >::iterator]':
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:185:11: required by substitution of 'template<class _Tp> using iter_difference_t = std::__detail::__iter_diff_t<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> [with _Tp = squared_view<std::ranges::ref_view<std::vector<int> > >::iterator]'
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:511:11: required from 'constexpr auto std::ranges::__cust_access::_Begin::operator()(_Tp&&) const [with _Tp = squared_view<std::ranges::ref_view<std::vector<int> > >&]'
C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:72:27: required from here
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:180:13: error: no type named 'difference_type' in 'std::__detail::__iter_traits<squared_view<std::ranges::ref_view<std::vector<int> > >::iterator, std::incrementable_traits<squared_view<std::ranges::ref_view<std::vector<int> > >::iterator> >' {aka 'struct std::incrementable_traits<squared_view<std::ranges::ref_view<std::vector<int> > >::iterator>'}
180 | using __iter_diff_t = typename
| ^~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h: In instantiation of 'constexpr auto std::ranges::__cust_access::_Begin::operator()(_Tp&&) const [with _Tp = squared_view<std::ranges::ref_view<std::vector<int> > >&]':
C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:72:27: required from here
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:512:21: note: nested requirement '__is_signed_integer_like<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>' is not satisfied, because
512 | requires __detail::__is_signed_integer_like<iter_difference_t<_Iter>>;
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:498:15: required for the satisfaction of '__is_signed_integer_like<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>'
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:499:2: note: no operand of the disjunction is satisfied
498 | concept __is_signed_integer_like = signed_integral<_Tp>
| ~~~~~~~~~~~~~~~~~~~~
499 | || same_as<_Tp, __max_diff_type>;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:498:42: note: the operand 'signed_integral<_Tp>' is unsatisfied because
498 | concept __is_signed_integer_like = signed_integral<_Tp>
| ^~~~~~~~~~~~~~~~~~~~
499 | || same_as<_Tp, __max_diff_type>;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/concepts:102:13: required for the satisfaction of 'integral<_Tp>' [with _Tp = typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>::type>::type> >::type::difference_type]
C:/msys64/mingw64/include/c++/10.1.0/concepts:105:13: required for the satisfaction of 'signed_integral<_Tp>' [with _Tp = typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>::type>::type> >::type::difference_type]
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:498:15: required for the satisfaction of '__is_signed_integer_like<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>'
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:512:11: error: no type named 'difference_type' in 'using type = struct std::incrementable_traits<squared_view<std::ranges::ref_view<std::vector<int> > >::iterator>' {aka 'struct std::incrementable_traits<squared_view<std::ranges::ref_view<std::vector<int> > >::iterator>'}
512 | requires __detail::__is_signed_integer_like<iter_difference_t<_Iter>>;
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:499:5: note: the operand 'same_as<_Tp, __int128>' is unsatisfied because
498 | concept __is_signed_integer_like = signed_integral<_Tp>
| ~~~~~~~~~~~~~~~~~~~~
499 | || same_as<_Tp, __max_diff_type>;
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/concepts:57:15: required for the satisfaction of '__same_as<_Tp, _Up>' [with _Tp = typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>::type>::type> >::type::difference_type; _Up = __int128]
C:/msys64/mingw64/include/c++/10.1.0/concepts:62:13: required for the satisfaction of 'same_as<_Tp, __int128>' [with _Tp = typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>::type>::type> >::type::difference_type]
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:498:15: required for the satisfaction of '__is_signed_integer_like<typename std::__detail::__iter_traits_impl<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type, std::incrementable_traits<typename std::remove_cv<typename std::remove_reference<_Tp>::type>::type> >::type::difference_type>'
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:512:11: error: no type named 'difference_type' in 'using type = struct std::incrementable_traits<squared_view<std::ranges::ref_view<std::vector<int> > >::iterator>' {aka 'struct std::incrementable_traits<squared_view<std::ranges::ref_view<std::vector<int> > >::iterator>'}
512 | requires __detail::__is_signed_integer_like<iter_difference_t<_Iter>>;
| ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/c++/10.1.0/string:54,
from C:/msys64/mingw64/include/c++/10.1.0/bits/locale_classes.h:40,
from C:/msys64/mingw64/include/c++/10.1.0/bits/ios_base.h:41,
from C:/msys64/mingw64/include/c++/10.1.0/ios:42,
from C:/msys64/mingw64/include/c++/10.1.0/ostream:38,
from C:/msys64/mingw64/include/c++/10.1.0/iostream:39,
from C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:1:
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:398:7: note: the operand '__adl_begin<_Tp>' is unsatisfied because
397 | requires is_array_v<remove_reference_t<_Tp>> || __member_begin<_Tp>
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398 | || __adl_begin<_Tp>
| ~~~^~~~~~~~~~~~~~~~
In file included from C:/msys64/mingw64/include/c++/10.1.0/bits/stl_iterator_base_types.h:71,
from C:/msys64/mingw64/include/c++/10.1.0/bits/stl_algobase.h:65,
from C:/msys64/mingw64/include/c++/10.1.0/bits/char_traits.h:39,
from C:/msys64/mingw64/include/c++/10.1.0/ios:40,
from C:/msys64/mingw64/include/c++/10.1.0/ostream:38,
from C:/msys64/mingw64/include/c++/10.1.0/iostream:39,
from C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:1:
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:856:15: required for the satisfaction of '__adl_begin<_Tp>' [with _Tp = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >&]
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:857:5: in requirements with '_Tp& __t' [with _Tp = squared_view<std::ranges::ref_view<std::vector<int, std::allocator<int> > > >&]
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:859:28: note: the required expression 'std::__detail::__decay_copy(std::__detail::begin(__t))' is invalid, because
859 | { __detail::__decay_copy(begin(__t)) } -> input_or_output_iterator;
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:859:34: error: call of overloaded 'begin(squared_view<std::ranges::ref_view<std::vector<int> > >&)' is ambiguous
859 | { __detail::__decay_copy(begin(__t)) } -> input_or_output_iterator;
| ~~~~~^~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:852:10: note: candidate: 'void std::__detail::begin(auto:1&) [with auto:1 = squared_view<std::ranges::ref_view<std::vector<int> > >]' (deleted)
852 | void begin(auto&) = delete;
| ^~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/iterator_concepts.h:853:10: note: candidate: 'void std::__detail::begin(const auto:2&) [with auto:2 = squared_view<std::ranges::ref_view<std::vector<int> > >]' (deleted)
853 | void begin(const auto&) = delete;
| ^~~~~
In file included from C:/msys64/mingw64/include/c++/10.1.0/string:54,
from C:/msys64/mingw64/include/c++/10.1.0/bits/locale_classes.h:40,
from C:/msys64/mingw64/include/c++/10.1.0/bits/ios_base.h:41,
from C:/msys64/mingw64/include/c++/10.1.0/ios:42,
from C:/msys64/mingw64/include/c++/10.1.0/ostream:38,
from C:/msys64/mingw64/include/c++/10.1.0/iostream:39,
from C:\Users\Lenovo\CLionProjects\EasyNamespace\main.cpp:1:
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:51:5: note: candidate: 'constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = squared_view<std::ranges::ref_view<std::vector<int> > >; decltype (__cont.begin()) = squared_view<std::ranges::ref_view<std::vector<int> > >::iterator]'
51 | begin(_Container& __cont) -> decltype(__cont.begin())
| ^~~~~
C:/msys64/mingw64/include/c++/10.1.0/bits/range_access.h:61:5: note: candidate: 'constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = squared_view<std::ranges::ref_view<std::vector<int> > >; decltype (__cont.begin()) = squared_view<std::ranges::ref_view<std::vector<int> > >::iterator]'
61 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ^~~~~
mingw32-make.exe[3]: *** [CMakeFiles\EasyNamespace.dir\build.make:82: CMakeFiles/EasyNamespace.dir/main.cpp.obj] Error 1
mingw32-make.exe[2]: *** [CMakeFiles\Makefile2:95: CMakeFiles/EasyNamespace.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles\Makefile2:102: CMakeFiles/EasyNamespace.dir/rule] Error 2
mingw32-make.exe: *** [Makefile:137: EasyNamespace] Error 2
我到底错过了什么?我如何正确地创建我自己的<代码>
您的迭代器不满足std::input_or_output_iterator
概念。
它需要是< code > STD::weakly _ incrementable ,这要求< code > STD::ITER _ difference _ t 有效。目前,由于您的类型没有< code>difference_type成员类型或specialiase < code > STD::iterator _ traits ,因此< code > STD::ITER _ difference _ t 无效。
所以只需添加一个别名:
template <typename Range>
struct squared_view<Range>::iterator {
using difference_type = std::iter_difference_t<std::ranges::iterator_t<Range>>;
// ...
};
问题内容: Python范围规则到底是什么? 如果我有一些代码: 在哪里找到?一些可能的选择包括以下列表: 在随附的源文件中 在类名称空间中 在函数定义中 在for循环中,索引变量 在for循环内 当函数传递到其他地方时,执行期间还会有上下文。也许lambda函数传递的方式有所不同? 某个地方必须有一个简单的参考或算法。对于中级Python程序员而言,这是一个令人困惑的。 问题答案: 实际上,这是
要创建可视化视图: 点击左侧导航栏的 Visualize 。 点击 Create new visualization 按钮或 + 按钮。 选择视图类型: 基础图形 Line, Area and Bar charts 在X/Y图中比较两个不同的序列。 Heat maps 使用矩阵的渐变单元格. Pie chart 显示每个来源的占比。 数据 Data table 显示一个组合聚合的原始数据。 Met
任何编程中的范围都是程序的一个区域,其中定义的变量可以存在,并且超出该变量,无法访问它。 有三个地方可以用C编程语言声明变量 - 在函数或块内部,称为local变量。 在所有函数之外,称为global变量。 在函数参数的定义中称为formal参数。 让我们了解什么是local和global变量,以及formal参数。 局部变量 (Local Variables) 在函数或块内声明的变量称为局部变量
问题内容: 我有一个像这样的表 我想创建一个视图,以下列格式提供数据 我对视图不够熟悉,所以我需要一些指导。 谢谢 问题答案: 您可以使用递归CTE完成此操作
null null 我怎样才能想象这些工作类型之间的关系?还有其他插件支持这些类型吗?
如果您在开发共享库的公司工作,或者您在开源或商业库中工作,则可能需要开发自己的自动配置。 自动配置类可以捆绑在外部jar中,仍然可以通过Spring Boot获取。 自动配置可以与“启动器”相关联,该“启动器”提供自动配置代码以及您将使用它的典型库。 我们首先介绍了构建自己的自动配置需要了解的内容,然后我们将继续介绍创建自定义启动器所需的典型步骤。 可以使用演示项目来展示如何逐步创建启动器。 4.