次の方法で共有


add_reference クラス

型から型への参照を作成します。

template<class Ty>
    struct add_reference;

パラメーター

  • Ty
    変更する型。

解説

この型修飾子のインスタンスは、Ty が参照である場合は、修飾型 Ty を保持します。それ以外の場合は、Ty& を保持します。

使用例

 

// std_tr1__type_traits__add_reference.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
int main() 
    { 
    int val = 0; 
    std::add_reference<int>::type p = (int&)val; 
 
    p = p;  // to quiet "unused" warning 
    std::cout << "add_reference<int> == " 
        << typeid(p).name() << std::endl; 
 
    return (0); 
    } 
 
  

必要条件

ヘッダー : <type_traits>

名前空間: std

参照

関連項目

<type_traits>

remove_reference クラス

その他の技術情報

<type_traits> メンバー