2
:부스트없이 BOOST_DEDUCED_TYPENAME의 구현 다음 코드가
template<typename ValueType>
ValueType any_cast(any & operand)
{
typedef BOOST_DEDUCED_TYPENAME remove_reference<ValueType>::type nonref;
nonref * result = any_cast<nonref>(&operand);
if(!result)
boost::throw_exception(bad_any_cast());
// Attempt to avoid construction of a temporary object in cases when
// `ValueType` is not a reference. Example:
// `static_cast<std::string>(*result);`
// which is equal to `std::string(*result);`
typedef BOOST_DEDUCED_TYPENAME boost::mpl::if_<
boost::is_reference<ValueType>,
ValueType,
BOOST_DEDUCED_TYPENAME boost::add_reference<ValueType>::type
>::type ref_type;
return static_cast<ref_type>(*result);
}
이 Boost
없이 BOOST_DEDUCED_TYPENAME
을 구현 가능한 거기가? 나는 C++11
만 사용할 수 있습니다.
'typename' 키워드의 문제점은 무엇입니까? –
@remyabel,이 경우'typename'을 사용하여 어떤 예를들 수 있습니까? – Denis