Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

is_const Class

Tests if type is const.

template<class Ty>
    struct is_const;
Ty

The type to query.

An instance of the type predicate holds true if Ty is const-qualified.

 

// std_tr1__type_traits__is_const.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
struct trivial 
    { 
    int val; 
    }; 
 
int main() 
    { 
    std::cout << "is_const<trivial> == " << std::boolalpha 
        << std::tr1::is_const<trivial>::value << std::endl; 
    std::cout << "is_const<const trivial> == " << std::boolalpha 
        << std::tr1::is_const<const trivial>::value << std::endl; 
    std::cout << "is_const<int> == " << std::boolalpha 
        << std::tr1::is_const<int>::value << std::endl; 
    std::cout << "is_const<const int> == " << std::boolalpha 
        << std::tr1::is_const<const int>::value << std::endl; 
 
    return (0); 
    } 
 
is_const<trivial> == false is_const<const trivial> == true is_const<int> == false is_const<const int> == true

Header: <type_traits>

Namespace: std::tr1

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.