diff DEPENDENCIES/generic/include/boost/units/detail/utility.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
line wrap: on
line diff
--- a/DEPENDENCIES/generic/include/boost/units/detail/utility.hpp	Fri Sep 04 12:01:02 2015 +0100
+++ b/DEPENDENCIES/generic/include/boost/units/detail/utility.hpp	Mon Sep 07 11:12:49 2015 +0100
@@ -11,18 +11,9 @@
 #ifndef BOOST_UNITS_UTILITY_HPP
 #define BOOST_UNITS_UTILITY_HPP
 
-#include <cstdlib>
 #include <typeinfo>
 #include <string>
-
-#if defined(__GLIBCXX__) || defined(__GLIBCPP__)
-#define BOOST_UNITS_USE_DEMANGLING
-#include <cxxabi.h>
-#endif // __GNUC__
-
-#ifdef BOOST_UNITS_USE_DEMANGLING
-
-#include <boost/algorithm/string/replace.hpp>
+#include <boost/core/demangle.hpp>
 
 namespace boost {
 
@@ -34,71 +25,33 @@
 std::string
 demangle(const char* name)
 {
-    // need to demangle C++ symbols
-    char*       realname;
-    std::size_t len; 
-    int         stat;
-     
-    realname = abi::__cxa_demangle(name,NULL,&len,&stat);
-    
-    if (realname != NULL)
+    std::string demangled = core::demangle(name);
+
+    const std::string::size_type prefix_len = sizeof("boost::units::") - 1;
+    std::string::size_type i = 0;
+    for (;;)
     {
-        std::string   out(realname);
-        
-        std::free(realname);
-        
-        boost::replace_all(out,"boost::units::","");
-        
-        return out;
+        std::string::size_type pos = demangled.find("boost::units::", i, prefix_len);
+        if (pos == std::string::npos)
+            break;
+
+        demangled.erase(pos, prefix_len);
+        i = pos;
     }
-    
-    return std::string("demangle :: error - unable to demangle specified symbol");
+
+    return demangled;
 }
 
 } // namespace detail
 
 template<class L>
-std::string simplify_typename(const L& /*source*/)
+inline std::string simplify_typename(const L& /*source*/)
 {
-    const std::string   demangled = detail::demangle(typeid(L).name());
-
-    return demangled;
+    return detail::demangle(typeid(L).name());
 }
 
 } // namespace units
 
 } // namespace boost
 
-#else // BOOST_UNITS_USE_DEMANGLING
-
-namespace boost {
-
-namespace units {
-
-namespace detail {
-
-inline
-std::string
-demangle(const char* name)
-{
-    return name;
-}
-
-} // namespace detail
-
-template<class L>
-std::string simplify_typename(const L& /*source*/)
-{
-    return std::string(typeid(L).name());
-}
-
-} // namespace units
-
-} // namespace boost
-
-// To get system-specific predefined macros:
-// gcc -arch ppc -dM -E - < /dev/null | sort 
-
-#endif // BOOST_UNITS_USE_DEMANGLING
-
 #endif // BOOST_UNITS_UTILITY_HPP