Boost logo

Boost Users :

Subject: Re: [Boost-users] boost::ptr_vector::sort with c++11 lambdas
From: qplace (admin_at_[hidden])
Date: 2011-11-11 10:18:13


Thorsten Ottosen <thorsten.ottosen <at> dezide.com> writes:
> The first one is the correct one. But I think the problem is with
> indirect_fun, or the code surrounding it. Does this work:
>
> auto x = <lambda>;
>
> boost::indirect_fun<decltype(x)> fun(x);
>
> ?
>
> -Thorsten
>

int _tmain(int argc, _TCHAR* argv[])
{
        boost::ptr_vector<A> lst;
// lst.sort([&] (const A& v1, const A& v2) ->bool {return false;});

        auto x = [] (const A* v1, const A* v2) ->bool {return false;};
        boost::indirect_fun<decltype(x)> fun(x);

        lst.sort(fun);
        return 0;
}

The error message is the same. Complete output is shown below:
1>ClCompile:
1>c:\libraries\boost\boost_1_47_0\boost\utility\result_of.hpp(79): error
C2903: 'result' : symbol is neither a class template nor a function template
1> c:\libraries\boost\boost_1_47_0\boost\utility\result_of.hpp(87) :
see reference to class template
instantiation 'boost::detail::result_of_nested_result<F,FArgs>' being compiled
1> with
1> [
1> F=const boost::indirect_fun<`anonymous-namespace'::<lambda0>>,
1> FArgs=const boost::indirect_fun<`anonymous-
namespace'::<lambda0>> (const A &,const A &)
1> ]
1> c:\libraries\boost\boost_1_47_0
\boost\utility\detail\result_of_iterate.hpp(33) : see reference to class
template
instantiation 'boost::detail::tr1_result_of_impl<F,FArgs,HasResultType>' being
compiled
1> with
1> [
1> F=const boost::indirect_fun<`anonymous-namespace'::<lambda0>>,
1> FArgs=const boost::indirect_fun<`anonymous-
namespace'::<lambda0>> (const A &,const A &),
1> HasResultType=false
1> ]
1> c:\libraries\boost\boost_1_47_0
\boost\utility\detail\result_of_iterate.hpp(81) : see reference to class
template instantiation 'boost::tr1_result_of<F>' being compiled
1> with
1> [
1> F=const boost::indirect_fun<`anonymous-namespace'::<lambda0>>
(const A &,const A &)
1> ]
1> c:\libraries\boost\boost_1_47_0\boost\ptr_container\indirect_fun.hpp
(41) : see reference to class template instantiation 'boost::result_of<F>'
being compiled
1> with
1> [
1> F=const boost::indirect_fun<`anonymous-namespace'::<lambda0>>
(const A &,const A &)
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0
\vc\include\algorithm(3720) : see reference to class template
instantiation 'boost::ptr_container_detail::make_lazy<Type,Dummy>' being
compiled
1> with
1> [
1> Type=boost::result_of<const boost::indirect_fun<`anonymous-
namespace'::<lambda0>> (const A &,const A &)>,
1> Dummy=void
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0
\vc\include\algorithm(3776) : see reference to function template
instantiation 'std::pair<_Ty1,_Ty2> std::_Unguarded_partition<_RanIt,_Pr>
(_RanIt,_RanIt,_Pr)' being compiled
1> with
1> [
1> _Ty1=void **,
1> _Ty2=void **,
1> _RanIt=void **,
1> _Pr=boost::void_ptr_indirect_fun<boost::indirect_fun<`anonymous-
namespace'::<lambda0>>,A>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0
\vc\include\algorithm(3806) : see reference to function template
instantiation 'void std::_Sort<void**,__w64 int,_Pr>(_RanIt,_RanIt,_Diff,_Pr)'
being compiled
1> with
1> [
1> _Pr=boost::void_ptr_indirect_fun<boost::indirect_fun<`anonymous-
namespace'::<lambda0>>,A>,
1> _RanIt=void **,
1> _Diff=__w64 int
1> ]
1> c:\libraries\boost\boost_1_47_0
\boost\ptr_container\ptr_sequence_adapter.hpp(601) : see reference to function
template instantiation 'void
std::sort<VoidIter,boost::void_ptr_indirect_fun<Fun,Arg1>>(_RanIt,_RanIt,_Pr)'
being compiled
1> with
1> [
1> VoidIter=std::_Vector_iterator<std::_Vector_val<void
*,std::allocator<void *>>>,
1> Fun=boost::indirect_fun<`anonymous-namespace'::<lambda0>>,
1> Arg1=A,
1> _RanIt=std::_Vector_iterator<std::_Vector_val<void
*,std::allocator<void *>>>,
1> _Pr=boost::void_ptr_indirect_fun<boost::indirect_fun<`anonymous-
namespace'::<lambda0>>,A>
1> ]
1> c:\libraries\boost\boost_1_47_0
\boost\ptr_container\ptr_sequence_adapter.hpp(607) : see reference to function
template instantiation 'void
boost::ptr_sequence_adapter<T,VoidPtrSeq,CloneAllocator>::sort<Compare>
(boost::void_ptr_iterator<VoidIter,T>,boost::void_ptr_iterator<VoidIter,T>,Compa
re)' being compiled
1> with
1> [
1> T=A,
1> VoidPtrSeq=std::vector<void *,std::allocator<void *>>,
1> CloneAllocator=boost::heap_clone_allocator,
1> Compare=boost::indirect_fun<`anonymous-namespace'::<lambda0>>,
1> VoidIter=std::_Vector_iterator<std::_Vector_val<void
*,std::allocator<void *>>>
1> ]
1> c:\test\ptr_pointer_lambda\ptr_pointer_lambda\ptr_pointer_lambda.cpp
(23) : see reference to function template instantiation 'void
boost::ptr_sequence_adapter<T,VoidPtrSeq,CloneAllocator>::sort<boost::indirect_f
un<Fun>>(Compare)' being compiled
1> with
1> [
1> T=A,
1> VoidPtrSeq=std::vector<void *,std::allocator<void *>>,
1> CloneAllocator=boost::heap_clone_allocator,
1> Fun=`anonymous-namespace'::<lambda0>,
1> Compare=boost::indirect_fun<`anonymous-namespace'::<lambda0>>
1> ]
1>c:\libraries\boost\boost_1_47_0\boost\utility\result_of.hpp(79): error
C2039: 'result' : is not a member of 'boost::indirect_fun<Fun>'
1> with
1> [
1> Fun=`anonymous-namespace'::<lambda0>
1> ]
1>c:\libraries\boost\boost_1_47_0\boost\utility\result_of.hpp(79): error
C2504: 'result' : base class undefined
1>c:\libraries\boost\boost_1_47_0\boost\utility\result_of.hpp(79): error C2143:
syntax error : missing ',' before '<'
1>c:\libraries\boost\boost_1_47_0\boost\ptr_container\indirect_fun.hpp(41):
error C2039: 'type' : is not a member of 'boost::result_of<F>'
1> with
1> [
1> F=const boost::indirect_fun<`anonymous-namespace'::<lambda0>>
(const A &,const A &)
1> ]
1>c:\libraries\boost\boost_1_47_0\boost\ptr_container\indirect_fun.hpp(41):
error C2146: syntax error : missing ';' before identifier 'type'
1>c:\libraries\boost\boost_1_47_0\boost\ptr_container\indirect_fun.hpp(41):
error C4430: missing type specifier - int assumed. Note: C++ does not support
default-int
1>c:\libraries\boost\boost_1_47_0\boost\ptr_container\indirect_fun.hpp(41):
error C2602: 'boost::ptr_container_detail::make_lazy<Type,Dummy>::type' is not
a member of a base class of 'boost::ptr_container_detail::make_lazy<Type,Dummy>'
1> with
1> [
1> Type=boost::result_of<const boost::indirect_fun<`anonymous-
namespace'::<lambda0>> (const A &,const A &)>,
1> Dummy=void
1> ]
1> c:\libraries\boost\boost_1_47_0\boost\ptr_container\indirect_fun.hpp
(41) : see declaration
of 'boost::ptr_container_detail::make_lazy<Type,Dummy>::type'
1> with
1> [
1> Type=boost::result_of<const boost::indirect_fun<`anonymous-
namespace'::<lambda0>> (const A &,const A &)>,
1> Dummy=void
1> ]
1>c:\libraries\boost\boost_1_47_0\boost\ptr_container\indirect_fun.hpp(41):
error C2868: 'boost::ptr_container_detail::make_lazy<Type,Dummy>::type' :
illegal syntax for using-declaration; expected qualified-name
1> with
1> [
1> Type=boost::result_of<const boost::indirect_fun<`anonymous-
namespace'::<lambda0>> (const A &,const A &)>,
1> Dummy=void
1> ]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net