|
Boost Users : |
From: Jeff Flinn (TriumphSprint2000_at_[hidden])
Date: 2008-03-06 18:14:50
Robert Dailey wrote:
> On Wed, Mar 5, 2008 at 10:36 AM, Robert Dailey <rcdailey_at_[hidden]
> <mailto:rcdailey_at_[hidden]>> wrote:
>
> On Tue, Mar 4, 2008 at 7:16 PM, Marshall Clow <marshall_at_[hidden]
> <mailto:marshall_at_[hidden]>> wrote:
>
> Would this work?
> std::for_each( myStrings.begin(), myStrings.end(), boost::bind(
> &DoFoo<std::string>, 5, _1 ) );
>
>
> Well, the example I gave was probably overly simple. The real
> example uses a boost::python::list, which can either take a char* or
> a std::string. At the time I'm doing the boost::bind, I do not know
> what type is being passed in.
>
>
>
> Below is the real example:
>
>
> //=========================================================================================
> bool PyInterpreter::SetSystemPath( std::vector<boost::filesystem::path>
> const& pathList )
> {
> bool success = true;
>
> try
> {
> using namespace boost::python;
>
> list newsyspath;
>
> std::for_each( pathList.begin(), pathList.end(), boost::bind(
> &list::insert<boost::filesystem::path>, newsyspath, 0, _1 ) );
>
> object sys = GetNamespace( "sys" );
> sys["path"] = newsyspath;
> }
>
> catch(...)
> {
> PyErr_Print();
> success = false;
> assert( 0 );
> }
>
> return false;
> }
did you try:
std::copy( pathList.begin(), pathList.end()
, std::back_inserter(list)
);
Jeff Flinn
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