class template
<type_traits>
std::is_trivialtemplate <class T> struct is_trivial;
Is trivial type
A trivial type is a type whose storage is contiguous (trivially copyable) and which only supports static default initialization (trivially default constructible), either cv-qualified or not. It includes scalar types, trivial classes and arrays of any such types.
A trivial class is a class (defined with class, struct or union) that is both trivially default constructible and trivially copyable, which implies that:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// is_trivial example
#include <iostream>
#include <type_traits>
class A {};
class B { B() {} };
class C : B {};
class D { virtual void fn() {} };
int main() {
std::cout << std::boolalpha;
std::cout << "is_trivial:" << std::endl;
std::cout << "int: " << std::is_trivial<int>::value << std::endl;
std::cout << "A: " << std::is_trivial<A>::value << std::endl;
std::cout << "B: " << std::is_trivial<B>::value << std::endl;
std::cout << "C: " << std::is_trivial<C>::value << std::endl;
std::cout << "D: " << std::is_trivial<D>::value << std::endl;
return 0;
}
is_trivial: int: true A: true B: false C: false D: false
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4