Opened 10 years ago

Closed 9 years ago

Last modified 9 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@…> 10 years ago.
indexed.cpp.patch (1.5 KB ) - added by Akira Takahashi <faithandbrave@…> 10 years ago.
add test

Download all attachments as: .zip

Change History (7)

by Akira Takahashi <faithandbrave@…>, 10 years ago

Attachment: indexed.hpp.patch added

by Akira Takahashi <faithandbrave@…>, 10 years ago

Attachment: indexed.cpp.patch added

add test

comment:1 by Nathan Ridge, 9 years ago

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

comment:2 by Nathan Ridge, 9 years ago

Thanks for the report and patch! Fixed in trunk.

comment:3 by Akira Takahashi, 9 years ago

Thanks for fix!

comment:4 by Nathan Ridge, 9 years ago

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 by Nathan Ridge, 9 years ago

Fixed for 1.54.

Note: See TracTickets for help on using tickets.