Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2006-05-30 05:27:22

João Abecasis wrote:
> and a slightly more convoluted for type_traits::is_pointer:
> #include <boost/type_traits/is_function.hpp>
> #include <boost/static_assert.hpp>
> void foo ();
> template <class F>
> void bar(F &)
> {
> BOOST_STATIC_ASSERT(boost::is_function<F const>::value);
> }
> template <class F>
> void baz(F const & f)
> {
> bar(f);
> }
> int main()
> {
> baz(foo);
> }

Right that should fail because:

*There is no such thing as a const-qualified function type in the C++

So argument deduction for baz would fail because it would have an invalid
signature. Actually, having said that, I seem to remember that behaviour
may have been changed by a DR that makes a cv-qualified function type (or
reference) the same as the non-cv-qualified type.

Unfortunately this is a bug that crops up in compilers from time to time,
often they allow you to generate cv-qualified function or reference types
inadvertently, but don't let you test for them with partial specialistion
because that part of the compiler "knows" the situation can never occur :-(

BTW your code compiles cleanly with gcc-3.4.4 and Intel 9 and VC++8 (after
removing the const from the function baz).

I'm surprised that gcc-4 has this issue, I'm fairly sure we looked at this
for gcc-2 and couldn't fix it (or maybe it was the cv-qualified reference
issue we looked at, I don't remember now). Whatever, if you have a patch
that works then yes lets fix is_function to workaround the problem for those
specific compilers.


> Both failing with gcc-4.x. The first test case also fails with
> gcc-3.2.3. while the second case fails for a completely different
> reason
> in overload resolution.
> For unpack_args I worked around these issues by applying remove_cv to
> pointers in general and also before testing with is_function. In
> either
> case cv-qualification shouldn't affect the type of the arguments or
> the result, which is what I'm interested in.
> Anyway I'm thinking that the solution could be moved upstream so
> others
> won't stumble upon the same issues. Thoughts?
> Best regards,
> João
> _______________________________________________
> Unsubscribe & other changes:

Boost list run by bdawes at, gregod at, cpdaniel at, john at