[type_traits] is_const and is_volatile broken for VC7.1

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

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.

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
participants (3)
-
John Maddock
-
Peder Holt
-
Shunsuke Sogame