• Class / Function / Type

      std::
    • Header file

      <>
    • Other / All

    最終更新日時(UTC):
    が更新

    履歴 編集

    class template
    <type_traits>

    std::remove_volatile

    namespace std {
      template <class T>
      struct remove_volatile {
        using type = ;
      };
    
      template <class T>
      using remove_volatile_t = typename remove_volatile<T>::type; // C++14
    }
    

    概要

    型のvolatile修飾を除去する。

    効果

    remove_volatileは、型Tに含まれる最上位のvolatile修飾を除去した型を、メンバ型typeとして定義する。

    #include <type_traits>
    
    static_assert(std::is_same<
            std::remove_volatile<volatile int>::type,
            int
        >::value,
        "transform from volatile int to int");
    
    static_assert(std::is_same<
            std::remove_volatile<volatile int&>::type,
            volatile int&
        >::value,
        "transform from volatile int& to volatile int&");
    
    static_assert(std::is_same<
            std::remove_volatile<volatile int*>::type,
            volatile int*
        >::value,
        "transform from volatile int* to volatile int*");
    
    static_assert(std::is_same<
            std::remove_volatile<int* volatile>::type,
            int*
        >::value,
        "transform from int* volatile to int*");
    
    int main() {}
    

    出力

    バージョン

    言語

    • C++11

    処理系

    • Clang: 3.0
    • GCC: 4.3.6
    • Visual C++: 2008 (std::tr1) , 2010 , 2012 , 2013 , 2015
      • remove_volatile_tは2013から

    参照