[type_traits] is_const and is_volatile broken for VC7.1

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[type_traits] is_const and is_volatile broken for VC7.1

Peder Holt
is_const and is_volatile fails to detect const and volatile arrays on VC7.1

The following code prints "Success" in VC6.5 and VC8, but "Failure" in VC7.1

#include <iostream>
#include <boost/type_traits.hpp>

void test(boost::mpl::true_) {
        std::cout<< "Success" << std::endl;
}

void test(boost::mpl::false_) {
        std::cout << "Failure" << std::endl;
}

int main()
{
        boost::is_const<int const[2]>::type const_;
        boost::is_volatile<int volatile[2]>::type volatile_;
        test(const_);
        test(volatile_);
        return 0;
}

Regards,
Peder

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [type_traits] is_const and is_volatile broken for VC7.1

John Maddock
> is_const and is_volatile fails to detect const and volatile arrays on
> VC7.1

Wierd, it's some kind of VC7.1-specific template deduction failure.  It's
fixed now in cvs, and the tests have been updated as well.

The only thing I haven't been able to fix are cv-qualified unbounded arrays
in VC6 and VC7:

is_const<const int[]>::value  => false on VC7 and earlier, and appears to be
unfixable for now.

John.

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Reply | Threaded
Open this post in threaded view
|

Re: [type_traits] is_const and is_volatile broken for VC7.1

Shunsuke Sogame
In reply to this post by Peder Holt
Peder Holt wrote:

> is_const and is_volatile fails to detect const and volatile arrays on VC7.1
>
> The following code prints "Success" in VC6.5 and VC8, but "Failure" in VC7.1
>
> #include <iostream>
> #include <boost/type_traits.hpp>
>
> void test(boost::mpl::true_) {
> std::cout<< "Success" << std::endl;
> }
>
> void test(boost::mpl::false_) {
> std::cout << "Failure" << std::endl;
> }
>
> int main()
> {
> boost::is_const<int const[2]>::type const_;
> boost::is_volatile<int volatile[2]>::type volatile_;
> test(const_);
> test(volatile_);
> return 0;
> }

I've encountered it, too.

FWIW, under VC7.1,
Writing 'const T' when T is an array type (eg. boost::is_xxx<const T>::type etc) doesn't work.
But boost::is_xxx<boost::add_const<T>::type>::type works fine.
That's why I always use boost::add_const.

--
Regards,
Shunsuke Sogame

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost