compiled with g++14.
#include <vector>
#include <ranges>
#include <algorithm>
#include <functional>
#include <generator>
#include <set>
using namespace std;
struct Edge
{
uint64_t u,v;
};
int main()
{
const vector<Edge> predecessor={};
auto walk = [&](int64_t u)->generator<int64_t>{
while (u != 0)
{
co_yield u;
u = predecessor[u].u;
}
};
const vector<int64_t> v={0,1,2};
const auto ms = v |
views::transform(walk) |
views::join |
ranges::to<multiset>() ;
return 0;
}
compiler error:
In file included from /opt/wandbox/gcc-head/include/c++/14.0.1/ext/alloc_traits.h:34,
from /opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_uninitialized.h:64,
from /opt/wandbox/gcc-head/include/c++/14.0.1/vector:65,
from prog.cc:1:
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/alloc_traits.h: In instantiation of 'static constexpr void std::allocator_traits<std::allocator<_Up> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = long int; _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Tp = std::_Rb_tree_node<long int>; allocator_type = std::allocator<std::_Rb_tree_node<long int> >]':
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_tree.h:593:32: required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(_Link_type, _Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Val = long int; _KeyOfValue = std::_Identity<long int>; _Compare = std::less<long int>; _Alloc = std::allocator<long int>; _Link_type = std::_Rb_tree_node<long int>*]'
593 | _Alloc_traits::construct(_M_get_Node_allocator(),
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
594 | __node->_M_valptr(),
| ~~~~~~~~~~~~~~~~~~~~
595 | std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_tree.h:610:21: required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Val = long int; _KeyOfValue = std::_Identity<long int>; _Compare = std::less<long int>; _Alloc = std::allocator<long int>; _Link_type = std::_Rb_tree_node<long int>*]'
610 | _M_construct_node(__tmp, std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_tree.h:1633:32: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Auto_node::_Auto_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Val = long int; _KeyOfValue = std::_Identity<long int>; _Compare = std::less<long int>; _Alloc = std::allocator<long int>]'
1633 | _M_node(__t._M_create_node(std::forward<_Args>(__args)...))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_tree.h:2445:13: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_equal(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Val = long int; _KeyOfValue = std::_Identity<long int>; _Compare = std::less<long int>; _Alloc = std::allocator<long int>; iterator = std::_Rb_tree<long int, long int, std::_Identity<long int>, std::less<long int>, std::allocator<long int> >::iterator]'
2445 | _Auto_node __z(*this, std::forward<_Args>(__args)...);
| ^~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_multiset.h:460:32: required from 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Compare = std::less<long int>; _Alloc = std::allocator<long int>; iterator = std::_Rb_tree<long int, long int, std::_Identity<long int>, std::less<long int>, std::allocator<long int> >::const_iterator]'
460 | { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/ranges:9341:18: required from 'constexpr _Cont std::ranges::to(_Rg&&, _Args&& ...) [with _Cont = std::multiset<long int, std::less<long int>, std::allocator<long int> >; _Rg = join_view<transform_view<ref_view<const std::vector<long int> >, main()::<lambda(int64_t)> > >; _Args = {}]'
9341 | __c.emplace(__c.end(), *__it);
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/ranges:9416:55: required from 'constexpr auto std::ranges::to(_Rg&&, _Args&& ...) [with _Cont = std::multiset; _Rg = join_view<transform_view<ref_view<const std::vector<long int> >, main()::<lambda(int64_t)> > >; _Args = {}]'
9416 | return ranges::to<_DeduceExpr3<_Cont, _Rg, _Args...>>(
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
9417 | std::forward<_Rg>(__r), std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/ranges:912:44: recursively required by substitution of 'template<class _Self, class _Range> requires __adaptor_invocable<_Adaptor, _Range, decltype((forward_like<_Self>)((declval<_Args>)()))...> constexpr auto std::ranges::views::__adaptor::_Partial<std::ranges::__detail::_To2<std::multiset> >::operator()(this _Self&&, _Range&&) [with _Self = std::ranges::__detail::_To2<std::multiset>; _Range = {}]'
912 | = requires { std::declval<_Adaptor>()(declval<_Args>()...); };
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/ranges:912:44: required by substitution of 'template<class _Self, class _Range> requires (__is_range_adaptor_closure<_Self>) && (__adaptor_invocable<_Self, _Range>) constexpr auto std::ranges::views::__adaptor::operator|(_Range&&, _Self&&) [with _Self = std::ranges::views::__adaptor::_Partial<std::ranges::__detail::_To2<std::multiset> >; _Range = std::ranges::join_view<std::ranges::transform_view<std::ranges::ref_view<const std::vector<long int> >, main()::<lambda(int64_t)> > >]'
prog.cc:30:30: required from here
30 | ranges::to<multiset>() ;
| ^
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/alloc_traits.h:536:28: error: no matching function for call to 'construct_at(long int*&, std::_Rb_tree_const_iterator<long int>, long int)'
536 | std::construct_at(__p, std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_iterator.h:78,
from /opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_algobase.h:67,
from /opt/wandbox/gcc-head/include/c++/14.0.1/vector:62:
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: candidate: 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...)'
94 | construct_at(_Tp* __location, _Args&&... __args)
| ^~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: template argument deduction/substitution failed:
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h: In substitution of 'template<class _Tp, class ... _Args> constexpr decltype (::new(void*(0)) _Tp) std::construct_at(_Tp*, _Args&& ...) [with _Tp = long int; _Args = {std::_Rb_tree_const_iterator<long int>, long int}]':
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/alloc_traits.h:536:21: required from 'static constexpr void std::allocator_traits<std::allocator<_Up> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = long int; _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Tp = std::_Rb_tree_node<long int>; allocator_type = std::allocator<std::_Rb_tree_node<long int> >]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 536 | std::construct_at(__p, std::forward<_Args>(__args)...);
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_tree.h:593:32: required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(_Link_type, _Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Val = long int; _KeyOfValue = std::_Identity<long int>; _Compare = std::less<long int>; _Alloc = std::allocator<long int>; _Link_type = std::_Rb_tree_node<long int>*]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 593 | _Alloc_traits::construct(_M_get_Node_allocator(),
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
594 | __node->_M_valptr(),
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~~~~
595 | std::forward<_Args>(__args)...);
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_tree.h:610:21: required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Val = long int; _KeyOfValue = std::_Identity<long int>; _Compare = std::less<long int>; _Alloc = std::allocator<long int>; _Link_type = std::_Rb_tree_node<long int>*]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 610 | _M_construct_node(__tmp, std::forward<_Args>(__args)...);
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_tree.h:1633:32: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Auto_node::_Auto_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>&, _Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Val = long int; _KeyOfValue = std::_Identity<long int>; _Compare = std::less<long int>; _Alloc = std::allocator<long int>]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 1633 | _M_node(__t._M_create_node(std::forward<_Args>(__args)...))
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_tree.h:2445:13: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_equal(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Val = long int; _KeyOfValue = std::_Identity<long int>; _Compare = std::less<long int>; _Alloc = std::allocator<long int>; iterator = std::_Rb_tree<long int, long int, std::_Identity<long int>, std::less<long int>, std::allocator<long int> >::iterator]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 2445 | _Auto_node __z(*this, std::forward<_Args>(__args)...);
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ^~~
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_multiset.h:460:32: required from 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::emplace(_Args&& ...) [with _Args = {std::_Rb_tree_const_iterator<long int>, long int}; _Key = long int; _Compare = std::less<long int>; _Alloc = std::allocator<long int>; iterator = std::_Rb_tree<long int, long int, std::_Identity<long int>, std::less<long int>, std::allocator<long int> >::const_iterator]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 460 | { return _M_t._M_emplace_equal(std::forward<_Args>(__args)...); }
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/ranges:9341:18: required from 'constexpr _Cont std::ranges::to(_Rg&&, _Args&& ...) [with _Cont = std::multiset<long int, std::less<long int>, std::allocator<long int> >; _Rg = join_view<transform_view<ref_view<const std::vector<long int> >, main()::<lambda(int64_t)> > >; _Args = {}]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 9341 | __c.emplace(__c.end(), *__it);
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/ranges:9416:55: required from 'constexpr auto std::ranges::to(_Rg&&, _Args&& ...) [with _Cont = std::multiset; _Rg = join_view<transform_view<ref_view<const std::vector<long int> >, main()::<lambda(int64_t)> > >; _Args = {}]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 9416 | return ranges::to<_DeduceExpr3<_Cont, _Rg, _Args...>>(
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
9417 | std::forward<_Rg>(__r), std::forward<_Args>(__args)...);
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/ranges:912:44: recursively required by substitution of 'template<class _Self, class _Range> requires __adaptor_invocable<_Adaptor, _Range, decltype((forward_like<_Self>)((declval<_Args>)()))...> constexpr auto std::ranges::views::__adaptor::_Partial<std::ranges::__detail::_To2<std::multiset> >::operator()(this _Self&&, _Range&&) [with _Self = std::ranges::__detail::_To2<std::multiset>; _Range = {}]'
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 912 | = requires { std::declval<_Adaptor>()(declval<_Args>()...); };
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/opt/wandbox/gcc-head/include/c++/14.0.1/ranges:912:44: required by substitution of 'template<class _Self, class _Range> requires (__is_range_adaptor_closure<_Self>) && (__adaptor_invocable<_Self, _Range>) constexpr auto std::ranges::views::__adaptor::operator|(_Range&&, _Self&&) [with _Self = std::ranges::views::__adaptor::_Partial<std::ranges::__detail::_To2<std::multiset> >; _Range = std::ranges::join_view<std::ranges::transform_view<std::ranges::ref_view<const std::vector<long int> >, main()::<lambda(int64_t)> > >]'
prog.cc:30:30: required from here
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: 30 | ranges::to<multiset>() ;
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:94:5: note: | ^
/opt/wandbox/gcc-head/include/c++/14.0.1/bits/stl_construct.h:96:17: error: new initializer expression list treated as compound expression [-fpermissive]
96 | -> decltype(::new((void*)0) _Tp(std::declval<_Args>()...))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~