Boost logo

Boost Users :

From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2006-06-24 15:22:22


Dave,

thanks for your answer. I think this should be definitely a part of FAQ,
otherwise someone could spent endless hours on matters why some of boost
classes do not work as expected.

I have one more question. I tried the following code with VC 8.0:

#include <boost/mpl/has_xxx.hpp>
struct test2 { typedef int xxx; };

BOOST_MPL_HAS_XXX_TRAIT_DEF(has_xxx)
typedef has_xxx my_test;

And got a compiler error:

main.cpp(22) : error C2146: syntax error : missing ';' before identifier
'my_test'

Somehow the macro was not expanded. I replaced xxx with some other name
before but end up in compiler errors, so that I decided to check if the
standard example is compilable at all by using the typedef.

Do you have any suggestions?

Thanks,
Ovanes

-----Original Message-----
From: David Abrahams [mailto:dave_at_[hidden]]
Sent: Saturday, June 24, 2006 04:51
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] inspecting templates and boost::is_pointer

"Ovanes Markarian" <om_boost_at_[hidden]> writes:

> Hello all,
>
> I am trying to specialize boost::is_pointer so, that it can determine
> if a type is a pointer wrapper (shared_ptr, auto_ptr, weak_ptr).

First of all, don't do that. It's a really bad idea, and it will probably
break some (Boost) library code. is_pointer is supposed to detect real
pointers, and if you start changing what it does with other types, you'll
break the expectations of every bit of code that currently uses is_pointer.
This has come up before, so maybe it should be a FAQ (John?)

> Does anybody has ideas how this can be done? May be it would be
> possible to handle if e.g. one can determine if a class/struct has
> some typedef inside:

http://www.boost.org/libs/mpl/doc/refmanual/has-xxx-trait-def.html

--
Dave Abrahams
Boost Consulting
www.boost-consulting.com

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