
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of David Abrahams Sent: Tuesday, July 26, 2005 11:01 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Iterators] Change in transform_iterator from 1.31 to 1.32?
"Nat Goodspeed" <ngoodspeed@solidworks.com> writes:
[Nat] boost::bind() is a runtime expression. I need to write a typedef for const_iterator before we get anywhere near that point. How can I use a type defined on the bind object for the typedef I need?
If the bind documentation doesn't tell you the type of that object (does it?), then officially you can't.
[Nat] This page: http://www.boost.org/libs/bind/bind.html#Interface uses 'unspecified-N' as the type returned by boost::bind().
Unofficially, you could pass the result of the bind expression to a function template that does something illegal on it, like
template <class F> void show_me_the_type(F const& f) { f += "hello"; }
and your compiler will probably show it to you.
[Nat] Heh, a useful trick to remember. I do need a reference, so I'm using Peter Dimov's suggested bind<R>() syntax. With this construct: show_me_the_type(boost::bind<const MapType::mapped_type&> (&MapType::value_type::second, _1)); The type described in the compiler output translates to: boost::_bi::bind_t< const MapType::mapped_type&, (ugly pointer-to-data-member syntax), boost::_bi::list1<boost::_bi::list_av_1<boost::arg<1> >::B1>
Forgive me, but that seems a bit too implementation-dependent to capture in my own code. I do want to be able to migrate forward to Boost 1.33 and beyond... As far as I'm aware, the only documented way to capture an object created by boost::bind() is to use boost::function. I understand your point about the inefficiency of using boost::function in my const_iterator type, but right now I know no better way to express it. Perhaps it would be useful to augment bind.hpp with a companion template that could reliably describe the type of the object produced by a particular call to boost::bind()?