Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::experimental::any_cast

      From cppreference.com
      <cpp‎ |experimental‎ |any
       
       
       
       
       
      template<class ValueType>
          ValueType any_cast(const any& operand);
      (1)(library fundamentals TS)
      template<class ValueType>
          ValueType any_cast(any& operand);
      (2)(library fundamentals TS)
      template<class ValueType>
          ValueType any_cast(any&& operand);
      (3)(library fundamentals TS)
      template<class ValueType>
         const ValueType* any_cast(const any* operand)noexcept;
      (4)(library fundamentals TS)
      template<class ValueType>
          ValueType* any_cast(any* operand)noexcept;
      (5)(library fundamentals TS)

      Performs type-safe access to the contained object.

      For(1-3), the program is ill-formed ifValueType is not a reference andstd::is_copy_constructible<ValueType>::value isfalse.

      [edit]Parameters

      operand - targetany object

      [edit]Return value

      1) Returns*any_cast<std::add_const_t<std::remove_reference_t<ValueType>>>(&operand).
      2,3) Returns*any_cast<std::remove_reference_t<ValueType>>(&operand).
      4,5) Ifoperand is not a null pointer, and thetypeid of the requestedValueType matches that of the contents ofoperand, a pointer to the value contained byoperand, otherwise a null pointer.

      [edit]Exceptions

      1-3) Throwsbad_any_cast if thetypeid of the requestedValueType does not match that of the contents ofoperand.
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/experimental/any/any_cast&oldid=157714"

      [8]ページ先頭

      ©2009-2025 Movatter.jp