std::is_standard_layout
Материал из cppreference.com
|
|
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
| Заголовочный файл <type_traits>
|
||
| template< class T > struct is_standard_layout; |
(начиная с C++11) | |
Если
T является стандартным типом раскладки (т. е. скалярный тип, стандарт-класса макета, или массив такого типа / класса, возможно, резюме квалифицированных), обеспечивает постоянный член value равных true. Для любого другого типа, value является false.Original:
If
T is a standard layout type (that is, a scalar type, a standard-layout class, or an array of such type/class, possibly cv-qualified), provides the member constant value equal true. For any other type, value is false.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Стандартная раскладка-класс это класс, который
Original:
A standard-layout class is a class that
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
1. не имеет не статические данные пользователей, которые не являются стандартными-макета
Original:
1. has no non-static data members that aren't standard-layout
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2. не имеет виртуальные функции и не виртуальных базовых классов
Original:
2. has no virtual functions and no virtual base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3. имеет такой же контроль доступа для всех не-статических данных-членов
Original:
3. has the same access control for all non-static data members
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
4. не имеет базовых классов, которые не являются стандартными-макета
Original:
4. has no base classes that aren't standard-layout
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
5. либо не имеет базового класса с не статические данные члены или не имеет не статические данные члены в наиболее производный класс и только одна база с ними
Original:
5. either has no base class with non-static data members or has no non-static data members in the most derived class and only one base with them
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
6. не имеет базовые классы одного и того же типа, что и первый не-статический член данных
Original:
6. has no base classes of the same type as the first non-static data member
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Содержание |
Унаследован от std::integral_constant
Member constants
| value [static] |
true если T is a standard-layout type , false иначе Original: true if T is a standard-layout type , false otherwise The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public static константа-член) |
Member functions
| operator bool |
преобразует объект в bool, возвращает value Original: converts the object to bool, returns value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (public функция-член) |
Member types
| Type
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
value_type
|
bool
|
type
|
std::integral_constant<bool, value> |
[править] Notes
Указатель на стандартных макетов классов могут быть конвертированы (с reinterpret_cast) к указателю на свой первый не статические данные члены и наоборот.
Original:
A pointer to a standard-layout class may be converted (with reinterpret_cast) to a pointer to its first non-static data member and vice versa.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Если стандарт-макет союз имеет два или более стандартных макетов структуры, он имеет право инспектировать общую начальную часть из них.
Original:
If a standard-layout union holds two or more standard-layout structs, it is permitted to inspect the common initial part of them.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Макрос offsetof могут быть использованы только со стандартным макетом классов.
Original:
The macro offsetof can only be used with standard-layout classes.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[править] Пример
#include <iostream> #include <type_traits> struct A { int m; }; struct B { int m1; private: int m2; }; struct C { virtual void foo(); }; int main() { std::cout << std::boolalpha; std::cout << std::is_standard_layout<A>::value << '\n'; std::cout << std::is_standard_layout<B>::value << '\n'; std::cout << std::is_standard_layout<C>::value << '\n'; }
Вывод:
true false false
[править] См. также
| (C++11) |
checks if a type is trivially copyable (шаблон класса) |
| (C++11) |
проверяет, является ли тип обычный старый данных (POD) типа Original: checks if a type is plain-old data (POD) type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (шаблон класса) |
| байтовое смещение от начала стандартной верстки типа указанного члена Original: byte offset from the beginning of a standard-layout type to specified member The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (функция-макрос) | |