On Mon, Jun 16, 2008 at 10:45 AM, Marc Horowitz <marc@mit.edu> wrote:
"Ovanes Markarian" <om_boost@keywallet.com> writes:

>> in this case template deduction does not work (or works a bit
>> different as assumed).
>>
>> This one should work:
>> (std::tr1::bind(f, _1))(static_cast<const char*>(NULL));

This works, but it is inconvenient.  It is not always clear at first
what the type of an argument which takes NULL is, especially if one is
modifying existing code.  You can compile, see what the error message
says, and copy that type into the code, but I was hoping to avoid
this.
This is static type safety of C++. The next standard will introduce null_ptr. If used as you suggested, then nothing prevents this BAD code to compile:
 (std::tr1::bind(f, _1))(1);


>> NullPlaceholder works, because it makes the cast in operator() for
>> you.

Yes, I am aware of this, which is why I wrote it that way.  I was
hoping to learn if someone had developed a cleaner workaround, and to
get the documentation improved if not.
I don't see it as a workaround, but a clean approach to initialize pointer values with NULL-value only. This approach cleanly prevents the upper error case as well.



               Marc

Regards,
Ovanes