共用方式為


is_reference 類別

測試類型是否為參考。

template<class Ty>
    struct is_reference;

參數

  • Ty
    要查詢的類型。

備註

如果 Ty 類型是物件或函式的參考,則 predicate 類型的執行個體保留 true,否則保留 false。

範例

 

// std__type_traits__is_reference.cpp 
// compile with: /EHsc 
#include <type_traits> 
#include <iostream> 
 
struct trivial 
    { 
    int val; 
    }; 
 
int main() 
    { 
    std::cout << "is_reference<trivial> == " << std::boolalpha 
        << std::is_reference<trivial>::value << std::endl; 
    std::cout << "is_reference<trivial&> == " << std::boolalpha 
        << std::is_reference<trivial&>::value << std::endl; 
    std::cout << "is_reference<int()> == " << std::boolalpha 
        << std::is_reference<int()>::value << std::endl; 
    std::cout << "is_reference<int(&)()> == " << std::boolalpha 
        << std::is_reference<int(&)()>::value << std::endl; 
 
    return (0); 
    } 
 
  

需求

標頭:<type_traits>

命名空間: std

請參閱

參考

<type_traits>

is_pointer 類別

其他資源

<type_traits> 成員