lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 8f67514 1/2: Restrict scope of pragma


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 8f67514 1/2: Restrict scope of pragma
Date: Sun, 19 Mar 2017 12:16:28 -0400 (EDT)

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

    Restrict scope of pragma
    
    There was no need to include the entire function body in the scope of
    the pragma.
    
    Incidentally outdented preprocessor conditionals. Include guards should
    not induce an extra level of indentation for preprocessor directives in
    a header: the extra indentation would deviate from common practice
    without increasing clarity.
---
 bourn_cast.hpp | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/bourn_cast.hpp b/bourn_cast.hpp
index ab89b1e..293afdd 100644
--- a/bourn_cast.hpp
+++ b/bourn_cast.hpp
@@ -72,15 +72,15 @@
 template<typename To, typename From>
 inline To bourn_cast(From from)
 {
-#   if defined __GNUC__
-#       pragma GCC diagnostic push
-#       pragma GCC diagnostic ignored "-Wsign-compare"
-#   endif // defined __GNUC__
     using to_traits   = std::numeric_limits<To>;
     using from_traits = std::numeric_limits<From>;
     static_assert(  to_traits::is_specialized, "");
     static_assert(from_traits::is_specialized, "");
 
+#if defined __GNUC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wsign-compare"
+#endif // defined __GNUC__
     if(! to_traits::is_signed && from < 0)
         throw std::runtime_error("Cast would convert negative to unsigned.");
     if(from_traits::is_signed && from < to_traits::lowest())
@@ -88,9 +88,9 @@ inline To bourn_cast(From from)
     if(to_traits::max() < from)
         throw std::runtime_error("Cast would transgress upper limit.");
     return static_cast<To>(from);
-#   if defined __GNUC__
-#       pragma GCC diagnostic pop
-#   endif // defined __GNUC__
+#if defined __GNUC__
+#   pragma GCC diagnostic pop
+#endif // defined __GNUC__
 }
 
 #endif // bourn_cast_hpp



reply via email to

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