std::is_scalar
提供: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. |
| Defined in header <type_traits>
|
||
| template< class T > struct is_scalar; |
(C + + 11以来) | |
Tがスカラー型(つまり、任意のcv-修飾変異体を含む、算術型、列挙型、ポインタ、メンバへのポインタ、またはstd::nullptr_tである)である場合、メンバーが一定提供value等しいtrueを。その他のタイプのために、valuefalseです.Original:
If
T is a scalar type (that is, arithmetic type, enumeration type, pointer, pointer to member, or std::nullptr_t, including any cv-qualified variants), 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.
目次 |
Inherited from std::integral_constant
Member constants
| value [静的] |
true T is a scalar type もし、そうでなければfalse Original: true if T is a scalar 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. (公共の静的メンバ定数) |
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. (パブリックメンバ関数) |
Member types
| タイプ
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> |
[編集] ノート
言語機能(例えば仮想テーブルポインタ)で使用される隠されたメモリ位置を含むC + +のメモリモデルの個々のメモリ位置は、スカラー型を持っている(またはゼロ以外の長さの隣接するビットフィールドの並びです)。式の評価、スレッド間の同期、および順序依存で副作用の配列決定は、すべての個々のスカラーオブジェクトの用語で定義されてい.
Original:
Each individual memory location in the C++ memory model, including the hidden memory locations used by language features (e.g virtual table pointer), has scalar type (or is a sequence of adjacent bit-fields of non-zero length). Sequencing of side-effects in expression evaluation, interthread synchronization, and dependency ordering are all defined in terms of individual scalar objects.
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.
[編集] 可能な実装
template< class T > struct is_scalar : std::integral_constant<bool, std::is_arithmetic<T>::value || std::is_enum<T>::value || std::is_pointer<T>::value || std::is_member_pointer<T>::value || std::is_same<std::nullptr_t, typename std::remove_cv<T>::type>::value> {}; |
[編集] 例
#include <iostream> #include <type_traits> int main() { class cls {}; std::cout << (std::is_scalar<int>::value ? "T is scalar" : "T is not a scalar") << '\n'; std::cout << (std::is_scalar<cls>::value ? "T is scalar" : "T is not a scalar") << '\n'; }
Output:
T is scalar T is not a scalar
[編集] も参照してください
| (C++11) |
タイプかどうかをチェックするには、算術型である Original: checks if a type is arithmetic type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |
| (C++11) |
タイプかどうかをチェックするには、列挙型です Original: checks if a type is an enumeration type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |
| (C++11) |
タイプかどうかをチェックするには、ポインタ型です Original: checks if a type is a pointer type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |
| (C++11) |
checks if a type is a pointer to a non-static member function or object (クラステンプレート) |