Boost logo

Boost Users :

Subject: Re: [Boost-users] [Bind] Unexpected behavior when binding constchar* to function
From: Joseph Gauterin (joseph.gauterin_at_[hidden])
Date: 2010-04-28 05:04:10


>My point is that difference between binding to echo and echo2 (string
>vs. const char*) should not lead do different behavior. Otherwise user
>has to be very careful on signature of bind'ed function.

Passing a std::string vs a const char* to boost::bind should have as
close as possible to same behaviour as passing that parameter to a
normal C++ function..

>To be serious: library should naturally promote its proper usage. Code
>like "boost::bind(echo1, "abc")" looks natural, does not emit any
>warning, and is dangerous.
That code is safe - the lifetime of string literals is the lifetime of
the program.

Just to be clear, using char*s as strings is tricky and error prone -
but that is a problem with C++, not a problem with boost.


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