I would like to write something like this, which cannot be compiled:
std::vector<A> as;
std::vector<B> bs( as.size() );
std::transform( as.beginn(), as.end(), bs.begin(), boost::lexical_cast<B> );
But this is not working, so I created a functor which is doing this for me:
template<typename Dest>
struct lexical_transform
{
template<typename Src>
Dest operator()( const Src& src ) const
{
return boost::lexical_cast<Dest>( src );
}
};
Is there an easier way to do this?