Thorsten Ottosen 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 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 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' 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' 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' being
compiled
1> with
1> [
1> Type=boost::result_of (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,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(_RanIt,_RanIt,_Diff,_Pr)'
being compiled
1> with
1> [
1> _Pr=boost::void_ptr_indirect_fun,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>(_RanIt,_RanIt,_Pr)'
being compiled
1> with
1> [
1> VoidIter=std::_Vector_iterator>>,
1> Fun=boost::indirect_fun<`anonymous-namespace'::<lambda0>>,
1> Arg1=A,
1> _RanIt=std::_Vector_iterator>>,
1> _Pr=boost::void_ptr_indirect_fun,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::sort<Compare>
(boost::void_ptr_iterator,boost::void_ptr_iterator,Compa
re)' being compiled
1> with
1> [
1> T=A,
1> VoidPtrSeq=std::vector>,
1> CloneAllocator=boost::heap_clone_allocator,
1> Compare=boost::indirect_fun<`anonymous-namespace'::<lambda0>>,
1> VoidIter=std::_Vector_iterator>>
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::sort(Compare)' being compiled
1> with
1> [
1> T=A,
1> VoidPtrSeq=std::vector>,
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' is not
a member of a base class of 'boost::ptr_container_detail::make_lazy'
1> with
1> [
1> Type=boost::result_of (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'
1> with
1> [
1> Type=boost::result_of (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' :
illegal syntax for using-declaration; expected qualified-name
1> with
1> [
1> Type=boost::result_of (const A &,const A &)>,
1> Dummy=void
1> ]