System::AsCast 方法

System::AsCast(const Source&) method

使用 ‘as’ 运算符将源类型转换为结果类型。在需要简单的类似构造函数的转换时使用。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::Static, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符将源类型转换为结果类型。当源类型和结果类型相同时使用。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::None, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符将源类型转换为结果类型。用于异常包装器。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::Exception, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。如果没有可用的转换,则返回 nullptr。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。用于将对象转换为异常。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::ObjectToException, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。如果没有可用的转换,则返回 nullptr。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。当源和结果都是智能指针时使用。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::Pointer, typename CastResult<Result>::type> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。如果没有可用的转换,则返回 nullptr。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。当源和结果都是智能指针时使用(在结果类型中显式包含 SmartPtr<…>)。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::PointerToPointer, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。如果没有可用的转换,则返回 nullptr。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。用于将对象拆箱为可空类型。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::UnboxingToNullable, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。如果没有可用的转换,则返回空的可空类型。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。无效的拆箱到非对象类型。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::InterfaceUnboxingToNullable, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

始终返回 null。

另见

System::AsCast(const Source&) method

无效的拆箱到非对象类型。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::InvalidUnboxing, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

始终返回 null。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。用于将可空对象装箱。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::NullableBoxing, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。用于将普通对象装箱。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::InterfaceBoxing, typename CastResult<Result>::type> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。用于将普通对象装箱。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::Boxing, typename CastResult<Result>::type> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。用于字符串拆箱。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::UnboxingToString, Result> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。用于 nullptr 转换。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::Null, typename CastResult<Result>::type> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。

另见

System::AsCast(const Source&) method

使用 ‘as’ 运算符进行转换,将源类型转换为结果类型。用于在数组之间进行转换。

template<typename Result,typename Source> std::enable_if_t<Details::CastType<Source, Result>::Array, typename CastResult<Result>::type> System::AsCast(const Source &value)
参数描述
源类型。
Result结果类型。
参数类型描述
valueconst Source&要转换的 Object

ReturnValue

转换结果。如果没有任何数组成员的可用转换,则返回 nullptr。

另见