Add compile time error mesage when attempting to call RTTI only method under MSVC

This commit is contained in:
Antony Polukhin
2013-11-12 10:44:52 +04:00
parent 736bdd4e04
commit 986ff55058

View File

@@ -276,6 +276,9 @@ inline const type_info& type_id_with_cvr() BOOST_NOEXCEPT {
/// producing a compile-time error with message: "boost::type_id_rtti_only(T&) requires RTTI"
template <class T>
inline const type_info& type_id_rtti_only(T& rtti_val) BOOST_NOEXCEPT {
#ifdef BOOST_NO_RTTI
BOOST_STATIC_ASSERT_MSG(sizeof(T) && false, "boost::type_id_rtti_only(T&) requires RTTI");
#endif
return static_cast<const type_info&>(typeid(rtti_val));
}
@@ -284,6 +287,9 @@ inline const type_info& type_id_rtti_only(T& rtti_val) BOOST_NOEXCEPT {
/// producing a compile-time error with message: "boost::type_id_rtti_only(T*) requires RTTI"
template <class T>
inline const type_info& type_id_rtti_only(T* rtti_val) {
#ifdef BOOST_NO_RTTI
BOOST_STATIC_ASSERT_MSG(sizeof(T) && false, "boost::type_id_rtti_only(T*) requires RTTI");
#endif
return static_cast<const type_info&>(typeid(rtti_val));
}