lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master cbd94a7 1/2: Simplify a diagnostic


From: Greg Chicares
Subject: [lmi-commits] [lmi] master cbd94a7 1/2: Simplify a diagnostic
Date: Wed, 11 Jan 2017 12:13:58 +0000 (UTC)

branch: master
commit cbd94a722917b617b2ad72247313bd24e397e5e4
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Simplify a diagnostic
    
    No longer even think of pandering to ancient compilers. A simpler
    diagnostic suffices if the static assertions are incorrect.
---
 numeric_io_cast.hpp |   30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/numeric_io_cast.hpp b/numeric_io_cast.hpp
index 4e94594..aa7306f 100644
--- a/numeric_io_cast.hpp
+++ b/numeric_io_cast.hpp
@@ -106,16 +106,14 @@ To numeric_io_cast(From from, To = To())
     return converter.operator()(from);
 }
 
-// A compile-time failure iff this template is ever instantiated is
-// desired, but the straightforward
-//   static_assert(0, "");
-// can fail even if it's never instantiated; instead, it is asserted
-// that both template parameters are void, which 14.1/7 forbids.
-//
-// In case that compile-time assertion doesn't fail, e.g. because the
-// borland compiler doesn't support the idiom, a run-time exception is
-// thrown from To().
-//
+/// A compile-time failure iff this template is ever instantiated is
+/// desired, but the straightforward
+///   static_assert(0, "");
+/// can fail even if it's never instantiated; instead, it is asserted
+/// that both template parameters are void, which 14.1/7 forbids.
+/// To make assurance doubly sure, a run-time exception is thrown in
+/// any case.
+
 template<typename To, typename From>
 struct numeric_converter
 {
@@ -124,17 +122,7 @@ struct numeric_converter
 
     To operator()(From const& from) const
         {
-        std::ostringstream err;
-        err
-            << "Cannot convert '"
-            << from
-            << "' from type "
-            << lmi::TypeInfo(typeid(From))
-            << " to type "
-            << lmi::TypeInfo(typeid(To))
-            << "'."
-            ;
-        throw std::runtime_error(err.str());
+        throw std::logic_error("Impossible numeric conversion.");
         }
 };
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]