From 28adee95188e7bdf2c876c09c5084f9e325f3a21 Mon Sep 17 00:00:00 2001 From: Minmin Gong Date: Tue, 3 Mar 2015 00:01:47 -0800 Subject: [PATCH] Using type_index to avoid RTTIs in program_options. (fixes #10347) --- include/boost/program_options/value_semantic.hpp | 8 ++++---- test/options_description_test.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/boost/program_options/value_semantic.hpp b/include/boost/program_options/value_semantic.hpp index bb377a2..6b01cf2 100644 --- a/include/boost/program_options/value_semantic.hpp +++ b/include/boost/program_options/value_semantic.hpp @@ -12,11 +12,11 @@ #include #include #include +#include #include #include -#include #include namespace boost { namespace program_options { @@ -174,7 +174,7 @@ namespace boost { namespace program_options { public: // Returns the type of the value described by this // object. - virtual const std::type_info& value_type() const = 0; + virtual const boost::typeindex::type_info& value_type() const = 0; // Not really needed, since deletion from this // class is silly, but just in case. virtual ~typed_value_base() {} @@ -359,9 +359,9 @@ namespace boost { namespace program_options { public: // typed_value_base overrides - const std::type_info& value_type() const + const boost::typeindex::type_info& value_type() const { - return typeid(T); + return boost::typeindex::type_id().type_info(); } diff --git a/test/options_description_test.cpp b/test/options_description_test.cpp index d443a7b..56233b6 100644 --- a/test/options_description_test.cpp +++ b/test/options_description_test.cpp @@ -28,12 +28,12 @@ void test_type() const typed_value_base* b = dynamic_cast (desc.find("foo", false).semantic().get()); BOOST_CHECK(b); - BOOST_CHECK(b->value_type() == typeid(int)); + BOOST_CHECK(b->value_type() == boost::typeindex::type_id().type_info()); const typed_value_base* b2 = dynamic_cast (desc.find("bar", false).semantic().get()); BOOST_CHECK(b2); - BOOST_CHECK(b2->value_type() == typeid(string)); + BOOST_CHECK(b2->value_type() == boost::typeindex::type_id().type_info()); } void test_approximation() -- 1.9.4.msysgit.2