Modify

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#7827 closed Bugs (fixed)

[range] cant compile r | indexed to range algorithm

Reported by: Akira Takahashi <faithandbrave@…> Owned by: Neil Groves
Milestone: To Be Determined Component: range
Version: Boost 1.52.0 Severity: Problem
Keywords: Cc:

Description

follow code is compile error:

#include <iostream>
#include <vector>
#include <boost/range/adaptor/indexed.hpp>
#include <boost/range/algorithm/min_element.hpp>

int main()
{
    std::vector<int> v = {3, 1, 4};
    auto m = boost::min_element(v | boost::adaptors::indexed(0));
    auto i = m.index();
    std::cout << i << std::endl;
    std::cout << *m << std::endl;
}
In file included from D:\GitHub\Boost\boost-svn/boost/range/concepts.hpp:19:0,
                 from D:\GitHub\Boost\boost-svn/boost/range/algorithm/equal.hpp:14,
                 from D:\GitHub\Boost\boost-svn/boost/range/iterator_range_core.hpp:29,
                 from D:\GitHub\Boost\boost-svn/boost/range/iterator_range.hpp:13,
                 from D:\GitHub\Boost\boost-svn/boost/range/adaptor/indexed.hpp:21,
                 from C:\language\cpp\main.cpp:3:
D:\GitHub\Boost\boost-svn/boost/concept_check.hpp: In instantiation of 'boost::DefaultConstructible<TT>::~DefaultConstructible() [with TT = boost::range_detail::indexed_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > >]':
D:\GitHub\Boost\boost-svn/boost/concept/usage.hpp:22:29:   required from 'boost::concepts::usage_requirements<Model>::~usage_requirements() [with Model = boost::DefaultConstructible<boost::range_detail::indexed_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > > >]'
D:\GitHub\Boost\boost-svn/boost/concept/detail/general.hpp:38:28:   required from 'static void boost::concepts::requirement<boost::concepts::failed************ Model::************>::failed() [with Model = boost::concepts::usage_requirements<boost::DefaultConstructible<boost::range_detail::indexed_iterator<__gnu_cxx::__normal_iterator<int*, std::vector<int> > > > >]'
...

Because indexed_iterator hasn't default constructor. I attach patch.

Attachments (2)

indexed.hpp.patch (620 bytes) - added by Akira Takahashi <faithandbrave@…> 5 years ago.
indexed.cpp.patch (1.5 KB) - added by Akira Takahashi <faithandbrave@…> 5 years ago.
add test

Download all attachments as: .zip

Change History (7)

Changed 5 years ago by Akira Takahashi <faithandbrave@…>

Attachment: indexed.hpp.patch added

Changed 5 years ago by Akira Takahashi <faithandbrave@…>

Attachment: indexed.cpp.patch added

add test

comment:1 Changed 4 years ago by Nathan Ridge

(In [84617]) [range] Make iterator of 'indexed' adaptor default-constructible (refs #7827).

comment:2 Changed 4 years ago by Nathan Ridge

Thanks for the report and patch! Fixed in trunk.

comment:3 Changed 4 years ago by Akira Takahashi

Thanks for fix!

comment:4 Changed 4 years ago by Nathan Ridge

Resolution: fixed
Status: newclosed

(In [84823]) [range] Merge Boost.Range bug fixes to release branch (fixes #6944; fixes #7407; fixes #7408; fixes #7731; fixes #7827; fixes #8338; fixes #8453).

comment:5 Changed 4 years ago by Nathan Ridge

Fixed for 1.54.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Neil Groves.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.