microsoft / Range-V3-VS2015

A fork of the popular range-v3 C++ library with support for the Visual Studio 2015 Update 3 VC++ compiler.
Other
115 stars 22 forks source link

compile error with remove_if #10

Closed nikobarli closed 7 years ago

nikobarli commented 7 years ago

Hi, I wonder why the following codes give me compile error (VS2015 Update 3):

    std::vector<std::vector<int>> a = { { 1, 2, 3, 4, 5 },{ 1, 2, 3, 4, 5 },{ 1, 2, 3, 4, 5 } };
    std::vector<int> result = a | view::transform([](auto && i) { return i | view::remove_if([](auto && j) { return j % 2; }); }) | view::for_each([](auto && i) { return yield_from(i); });

It gives the errors:

Error C2273 'function-style cast': illegal as right side of '->' operator
Error C2039 '=': is not a member of '`global namespace''

The error disappears if I replace view::remove_if(...) with view::transform(...).

The whole error message is as follows:

1>D:\Range-V3-VS2015\include\range/v3/view/remove_if.hpp(132): error C2273: 'function-style cast': illegal as right side of '->' operator 1> D:\Range-V3-VS2015\include\range/v3/view/remove_if.hpp(131): note: while compiling class template member function 'ranges::v3::remove_if_view<ranges::v3::range<std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>,_Cv_TiD> &ranges::v3::remove_if_view<ranges::v3::range<std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>,_Cv_TiD>::operator =(ranges::v3::remove_if_view<ranges::v3::range<std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>,_Cv_TiD> &&)' 1> with 1> [ 1> _Cv_TiD=main::::():: 1> ] 1> D:\Range-V3-VS2015\include\range/v3/view/join.hpp(112): note: see reference to function template instantiation 'ranges::v3::remove_if_view<ranges::v3::range<std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>,_Cv_TiD> &ranges::v3::remove_if_view<ranges::v3::range<std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>,_Cv_TiD>::operator =(ranges::v3::remove_if_view<ranges::v3::range<std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>,_Cv_TiD> &&)' being compiled 1> with 1> [ 1> _Cv_TiD=main::::():: 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/concepts.hpp(736): note: see reference to class template instantiation 'ranges::v3::remove_if_view<ranges::v3::range<std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>,_Cv_TiD>' being compiled 1> with 1> [ 1> _Cv_TiD=main::::():: 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/concepts.hpp(228): note: see reference to class template instantiation 'ranges::v3::concepts::models_helper<Concept,Fun,std::vector<int,std::allocator<_Ty>> &>' being compiled 1> with 1> [ 1> Concept=ranges::v3::concepts::Function, 1> Fun=ranges::v3::detail::pipeable_binder<std::_Binder<std::_Unforced,ranges::v3::view::remove_if_fn &,const std::_Ph<1> &,main::::()::>>, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\meta/meta.hpp(912): note: see reference to class template instantiation 'ranges::v3::concepts::models<ranges::v3::concepts::Function,Fun,std::vector<int,std::allocator<_Ty>> &>' being compiled 1> with 1> [ 1> Fun=ranges::v3::detail::pipeable_binder<std::_Binder<std::_Unforced,ranges::v3::view::remove_if_fn &,const std::_Ph<1> &,main::::()::>>, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\meta/meta.hpp(913): note: see reference to class template instantiation 'meta::v1::detail::and<ranges::v3::concepts::models<ranges::v3::concepts::Function,Fun,std::vector<int,std::allocator<_Ty>> &>>' being compiled 1> with 1> [ 1> Fun=ranges::v3::detail::pipeable_binder<std::_Binder<std::_Unforced,ranges::v3::view::remove_if_fn &,const std::_Ph<1> &,main::::()::>>, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/functional.hpp(564): note: see reference to class template instantiation 'meta::v1::detail::and<std::integral_constant<bool,true>,ranges::v3::concepts::models<ranges::v3::concepts::Function,Fun,std::vector<int,std::allocator<_Ty>> &>>' being compiled 1> with 1> [ 1> Fun=ranges::v3::detail::pipeable_binder<std::_Binder<std::_Unforced,ranges::v3::view::remove_if_fn &,const std::_Ph<1> &,main::::()::>>, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/concepts.hpp(736): note: see reference to function template instantiation 'ranges::v3::remove_if_view<ranges::v3::range<std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>,std::_Vector_iterator<std::_Vector_val<std::_Simple_types>>>,_Cv_TiD> main::::operator ()<std::vector<int,std::allocator<_Ty>>&>(std::vector<_Ty,std::allocator<_Ty>> &) const' being compiled 1> with 1> [ 1> _Cv_TiD=main::::()::, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/concepts.hpp(228): note: see reference to class template instantiation 'ranges::v3::concepts::models_helper<Concept,main::,std::vector<int,std::allocator<_Ty>> &>' being compiled 1> with 1> [ 1> Concept=ranges::v3::concepts::Function, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/functional.hpp(1063): note: see reference to class template instantiation 'ranges::v3::concepts::models<ranges::v3::concepts::Function,main::,std::vector<int,std::allocator<_Ty>> &>' being compiled 1> with 1> [ 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/concepts.hpp(228): note: see reference to class template instantiation 'ranges::v3::concepts::models_helper<Concept,_Cv_TiD,std::vector<int,std::allocator<_Ty>> &>' being compiled 1> with 1> [ 1> Concept=ranges::v3::concepts::Callable, 1> _Cv_TiD=main::, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\meta/meta.hpp(912): note: see reference to class template instantiation 'ranges::v3::concepts::models<ranges::v3::concepts::Callable,_Cv_TiD,std::vector<int,std::allocator<_Ty>> &>' being compiled 1> with 1> [ 1> _Cv_TiD=main::, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\meta/meta.hpp(913): note: see reference to class template instantiation 'meta::v1::detail::and<ranges::v3::concepts::models<ranges::v3::concepts::Callable,_Cv_TiD,std::vector<int,std::allocator<_Ty>> &>>' being compiled 1> with 1> [ 1> _Cv_TiD=main::, 1> _Ty=int 1> ] 1> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(1373): note: see reference to class template instantiation 'meta::v1::detail::and<ranges::v3::concepts::models<ranges::v3::concepts::InputRange,std::vector<std::vector<int,std::allocator<_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>> &>,ranges::v3::concepts::models<ranges::v3::concepts::Callable,_Cv_TiD,std::vector<_Ty,std::allocator<_Ty>> &>>' being compiled 1> with 1> [ 1> _Ty=int, 1> _Cv_TiD=main:: 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/concepts.hpp(228): note: see reference to class template instantiation 'ranges::v3::concepts::models_helper<Concept,Fun,std::vector<std::vector<int,std::allocator<_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>> &>' being compiled 1> with 1> [ 1> Concept=ranges::v3::concepts::Function, 1> Fun=ranges::v3::detail::pipeable_binder<std::_Binder<std::_Unforced,ranges::v3::view::transform_fn &,const std::_Ph<1> &,main::>>, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\meta/meta.hpp(912): note: see reference to class template instantiation 'ranges::v3::concepts::models<ranges::v3::concepts::Function,Fun,std::vector<std::vector<int,std::allocator<_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>> &>' being compiled 1> with 1> [ 1> Fun=ranges::v3::detail::pipeable_binder<std::_Binder<std::_Unforced,ranges::v3::view::transform_fn &,const std::_Ph<1> &,main::>>, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\meta/meta.hpp(913): note: see reference to class template instantiation 'meta::v1::detail::and<ranges::v3::concepts::models<ranges::v3::concepts::Function,Fun,std::vector<std::vector<int,std::allocator<_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>> &>>' being compiled 1> with 1> [ 1> Fun=ranges::v3::detail::pipeable_binder<std::_Binder<std::_Unforced,ranges::v3::view::transform_fn &,const std::_Ph<1> &,main::>>, 1> _Ty=int 1> ] 1> D:\Range-V3-VS2015\include\range/v3/utility/functional.hpp(564): note: see reference to class template instantiation 'meta::v1::detail::and<std::integral_constant<bool,true>,ranges::v3::concepts::models<ranges::v3::concepts::Function,Fun,std::vector<std::vector<int,std::allocator<_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>> &>>' being compiled 1> with 1> [ 1> Fun=ranges::v3::detail::pipeable_binder<std::_Binder<std::_Unforced,ranges::v3::view::transform_fn &,const std::_Ph<1> &,main::>>, 1> _Ty=int 1> ] 1>D:\Range-V3-VS2015\include\range/v3/view/remove_if.hpp(132): error C2039: '=': is not a member of '`global namespace''

CaseyCarter commented 7 years ago

I have good news and bad news. The bad news: it took me months to get around to examining this bug report. Sorry about that. The good news: this bug no longer reproduces. I believe it was fixed by b98768b50e7576bf99ce7b61186c668179823dcf.

nikobarli commented 7 years ago

Thank you !