From 986ff55058518e9c5dfb490c31a5b12aec65865c Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Tue, 12 Nov 2013 10:44:52 +0400 Subject: [PATCH] Add compile time error mesage when attempting to call RTTI only method under MSVC --- boost/type_index/type_info.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/boost/type_index/type_info.hpp b/boost/type_index/type_info.hpp index 552c645..410e3c4 100644 --- a/boost/type_index/type_info.hpp +++ b/boost/type_index/type_info.hpp @@ -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 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(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 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(typeid(rtti_val)); }