qicosmos/cosmos

编译LinqCpp出错

Justme0 opened this issue · 2 comments

你好!我在编译LinqCpp时出错了,修改了好多,现在只剩最后一个问题了,LinqCpp::where的参数类型是const F &f,test中给的实参是lambda表达式,用g++编译,报的错误是lambda closure没有提供赋值操作,但这里并没有赋值啊,还请指教。

下面是详细的编译信息,行号可能有不同,因为我修复了其他的编译错误。

In file included from /usr/include/boost/range/adaptors.hpp:15:0,
                 from LinqCpp.hpp:9,
                 from linq.cpp:7:
/usr/include/boost/range/adaptor/adjacent_filtered.hpp: In instantiation of ‘void boost::range_detail::skip_iterator<Iter, Pred, default_pass>::move_to_next_valid() [with Iter = boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >; Pred = boost::range_detail::unique_not_equal_to; bool default_pass = true]’:
/usr/include/boost/range/adaptor/adjacent_filtered.hpp:65:36:   required from ‘boost::range_detail::skip_iterator<Iter, Pred, default_pass>::skip_iterator(boost::range_detail::skip_iterator<Iter, Pred, default_pass>::iter_t, boost::range_detail::skip_iterator<Iter, Pred, default_pass>::iter_t, const Pred&) [with Iter = boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >; Pred = boost::range_detail::unique_not_equal_to; bool default_pass = true; boost::range_detail::skip_iterator<Iter, Pred, default_pass>::iter_t = boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >]’
/usr/include/boost/range/adaptor/adjacent_filtered.hpp:143:68:   required from ‘boost::range_detail::adjacent_filtered_range<P, R, default_pass>::adjacent_filtered_range(const P&, R&) [with P = boost::range_detail::unique_not_equal_to; R = boost::range_detail::filtered_range<TestLinqCpp()::<lambda(int)>, boost::iterator_range<__gnu_cxx::__normal_iterator<const int*, std::vector<int> > > >; bool default_pass = true]’
/usr/include/boost/range/adaptor/uniqued.hpp:40:50:   required from ‘boost::range_detail::uniqued_range<ForwardRng>::uniqued_range(ForwardRng&) [with ForwardRng = boost::range_detail::filtered_range<TestLinqCpp()::<lambda(int)>, boost::iterator_range<__gnu_cxx::__normal_iterator<const int*, std::vector<int> > > >]’
/usr/include/boost/range/adaptor/uniqued.hpp:50:47:   required from ‘boost::range_detail::uniqued_range<ForwardRng> boost::range_detail::operator|(ForwardRng&, boost::range_detail::unique_forwarder) [with ForwardRng = boost::range_detail::filtered_range<TestLinqCpp()::<lambda(int)>, boost::iterator_range<__gnu_cxx::__normal_iterator<const int*, std::vector<int> > > >]’
LinqCpp.hpp:101:50:   required from ‘cosmos::LinqCpp<boost::range_detail::uniqued_range<ForwardRng> > cosmos::LinqCpp<R>::distinct() [with R = boost::range_detail::filtered_range<TestLinqCpp()::<lambda(int)>, boost::iterator_range<__gnu_cxx::__normal_iterator<const int*, std::vector<int> > > >]’
linq.cpp:24:64:   required from here
/usr/include/boost/range/adaptor/adjacent_filtered.hpp:101:32: error: use of deleted function ‘boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >& boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >::operator=(const boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >&)’
                             it = m_last;
                                ^
In file included from /usr/include/boost/range/adaptor/filtered.hpp:16:0,
                 from /usr/include/boost/range/adaptors.hpp:17,
                 from LinqCpp.hpp:9,
                 from linq.cpp:7:
/usr/include/boost/iterator/filter_iterator.hpp:44:9: note: ‘boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >& boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >::operator=(const boost::filter_iterator<TestLinqCpp()::<lambda(int)>, __gnu_cxx::__normal_iterator<const int*, std::vector<int> > >&)’ is implicitly deleted because the default definition would be ill-formed:
   class filter_iterator
         ^
/usr/include/boost/iterator/filter_iterator.hpp:44:9: error: use of deleted function ‘TestLinqCpp()::<lambda(int)>& TestLinqCpp()::<lambda(int)>::operator=(const TestLinqCpp()::<lambda(int)>&)’
linq.cpp:24:22: note: a lambda closure type has a deleted copy assignment operator
       from(v).where([](int x) { return x % 2 != 0; }).distinct().to_vector();

你可以提一个pr,我看看。

大哥请将信息说全面一些,同时附上测试代码呢