|
Boost : |
From: jsiek_at_[hidden]
Date: 1999-12-22 18:15:28
Looks like that works for both EDG and g++ :)
Need to add a "typename" in front of the remove_const inside is_const.
Also I would suggest not giving the typedef the name "type" when it is
a static member. Perhaps "value" would be better? Also, for
portability, keep in mind that initialization of static members inside
the class definition doesn't work with some compilers (even when they
are bool/int/etc.) Might be easier to stick with enums.
Howard Hinnant writes:
> I've been playing around with an alternate implementation of is_const,
> and was wondering what if any compilers might support it:
>
> template <typename T> struct remove_const {typedef T type;};
> template <typename T> struct remove_const<T const> {typedef T type;};
>
> template <typename T, typename U> struct is_same {static const bool
> type = false;};
> template <typename T> struct is_same<T, T> {static const bool
> type = true;};
>
> template <typename T> struct is_const
> {static const bool type = !is_same<T, remove_const<T>::type>::type;};
>
> #include <iostream>
>
> int main()
> {
> std::cout << is_const<const int>::type << '\n';
> }
>
> -Howard
>
> ------------------------------------------------------------------------
> Want to send money instantly to anyone, anywhere, anytime?
> You can today at X.com - and we'll give you $20 to try it! Sign
> up today at X.com. It's quick, free, & there's no obligation!
> http://click.egroups.com/1/332/1/_/9351/_/945903928
>
> -- Create a poll/survey for your group!
> -- http://www.egroups.com/vote?listname=boost&m=1
>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk