description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | |||
---|---|---|---|---|---|---|---|---|
Learn more about: is_scalar Class |
is_scalar Class |
11/04/2016 |
|
|
a0cdfc9a-f27e-4808-890f-6ed7942db60c |
Tests if type is scalar.
template <class Ty>
struct is_scalar;
Ty
The type to query.
An instance of the type predicate holds true if the type Ty is an integral type, a floating point type, an enumeration type, a pointer type, or a pointer to member type, or a cv-qualified
form of one of them, otherwise it holds false.
// std__type_traits__is_scalar.cpp
// compile with: /EHsc
#include <type_traits>
#include <iostream>
struct trivial
{
int val;
};
int main()
{
std::cout << "is_scalar<trivial> == " << std::boolalpha
<< std::is_scalar<trivial>::value << std::endl;
std::cout << "is_scalar<trivial *> == " << std::boolalpha
<< std::is_scalar<trivial *>::value << std::endl;
std::cout << "is_scalar<int> == " << std::boolalpha
<< std::is_scalar<int>::value << std::endl;
std::cout << "is_scalar<float> == " << std::boolalpha
<< std::is_scalar<float>::value << std::endl;
return (0);
}
is_scalar<trivial> == false
is_scalar<trivial *> == true
is_scalar<int> == true
is_scalar<float> == true
Header: <type_traits>
Namespace: std