Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65871 - sandbox/chrono/boost/static_integer
From: vicente.botet_at_[hidden]
Date: 2010-10-10 08:45:32


Author: viboes
Date: 2010-10-10 08:45:30 EDT (Sun, 10 Oct 2010)
New Revision: 65871
URL: http://svn.boost.org/trac/boost/changeset/65871

Log:
Static_Integer metafunctions
Added:
   sandbox/chrono/boost/static_integer/static_abs.hpp (contents, props changed)
   sandbox/chrono/boost/static_integer/static_gcd.hpp (contents, props changed)
   sandbox/chrono/boost/static_integer/static_lcm.hpp (contents, props changed)
   sandbox/chrono/boost/static_integer/static_sign.hpp (contents, props changed)

Added: sandbox/chrono/boost/static_integer/static_abs.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/static_integer/static_abs.hpp 2010-10-10 08:45:30 EDT (Sun, 10 Oct 2010)
@@ -0,0 +1,54 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/static_integer for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_STATIC_INTEGER_STATIC_ABS_HPP
+#define BOOST_STATIC_INTEGER_STATIC_ABS_HPP
+
+#include <boost/cstdint.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost
+{
+
+namespace integer
+{
+ typedef boost::intmax_t static_abs_signed_type;
+ typedef boost::uintmax_t static_abs_unsigned_type;
+
+ template <static_abs_signed_type X>
+ struct static_signed_abs
+ : integral_constant<static_abs_signed_type,
+ X < 0 ? -X : X>
+ {};
+
+ template <static_abs_unsigned_type X>
+ struct static_unsigned_abs
+ : integral_constant<static_abs_unsigned_type,
+ X < 0 ? -X : X>
+ {};
+
+
+}
+}
+#endif

Added: sandbox/chrono/boost/static_integer/static_gcd.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/static_integer/static_gcd.hpp 2010-10-10 08:45:30 EDT (Sun, 10 Oct 2010)
@@ -0,0 +1,67 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/static_integer for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_STATIC_INTEGER_STATIC_GCD_HPP
+#define BOOST_STATIC_INTEGER_STATIC_GCD_HPP
+
+#include <boost/type_traits/integral_constant.hpp>
+#include <boost/cstdint.hpp>
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost
+{
+
+namespace integer
+{
+
+ typedef boost::intmax_t static_gcd_signed_type;
+ typedef boost::uintmax_t static_gcd_unsigned_type;
+
+ template <static_gcd_signed_type X, boost::intmax_t Y>
+ struct static_signed_gcd
+ : integral_constant<static_gcd_signed_type,
+ static_signed_gcd<Y, X % Y>::value>
+ {};
+
+ template <static_gcd_signed_type X>
+ struct static_signed_gcd<X, 0>
+ : integral_constant<static_gcd_signed_type,
+ X>
+ {};
+
+ template <static_gcd_unsigned_type X, boost::intmax_t Y>
+ struct static_unsigned_gcd
+ : integral_constant<static_gcd_unsigned_type,
+ static_unsigned_gcd<Y, X % Y>::value>
+ {};
+
+ template <static_gcd_unsigned_type X>
+ struct static_unsigned_gcd<X, 0>
+ : integral_constant<static_gcd_signed_type,
+ X>
+ {};
+}
+}
+
+
+#endif

Added: sandbox/chrono/boost/static_integer/static_lcm.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/static_integer/static_lcm.hpp 2010-10-10 08:45:30 EDT (Sun, 10 Oct 2010)
@@ -0,0 +1,58 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/static_integer for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_STATIC_INTEGER_STATIC_LCM_HPP
+#define BOOST_STATIC_INTEGER_STATIC_LCM_HPP
+
+#include <boost/cstdint.hpp>
+#include <boost/static_integer/static_gcd.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost
+{
+
+namespace integer
+{
+ typedef boost::intmax_t static_lcm_signed_type;
+ typedef boost::uintmax_t static_lcm_unsigned_type;
+
+ template <static_lcm_signed_type X, boost::intmax_t Y>
+ struct static_signed_lcm
+ : integral_constant<static_lcm_signed_type,
+ X / static_signed_gcd<X, Y>::value * Y>
+ {
+ };
+
+ template <static_lcm_unsigned_type X, boost::intmax_t Y>
+ struct static_unsigned_lcm
+ : integral_constant<static_lcm_unsigned_type,
+ X / static_unsigned_gcd<X, Y>::value * Y>
+ {
+ };
+
+}
+}
+
+
+#endif

Added: sandbox/chrono/boost/static_integer/static_sign.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono/boost/static_integer/static_sign.hpp 2010-10-10 08:45:30 EDT (Sun, 10 Oct 2010)
@@ -0,0 +1,55 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// (C) Copyright Vicente J. Botet Escriba 2010.
+// Distributed under the Boost
+// Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or
+// copy at http://www.boost.org/LICENSE_1_0.txt)
+//
+// See http://www.boost.org/libs/static_integer for documentation.
+//
+//////////////////////////////////////////////////////////////////////////////
+
+#ifndef BOOST_STATIC_INTEGER_STATIC_SIGN_HPP
+#define BOOST_STATIC_INTEGER_STATIC_SIGN_HPP
+
+#include <boost/cstdint.hpp>
+#include <boost/type_traits/integral_constant.hpp>
+
+//
+// We simply cannot include this header on gcc without getting copious warnings of the kind:
+//
+// boost/integer.hpp:77:30: warning: use of C99 long long integer constant
+//
+// And yet there is no other reasonable implementation, so we declare this a system header
+// to suppress these warnings.
+//
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+#pragma GCC system_header
+#endif
+
+namespace boost
+{
+
+namespace integer
+{
+ typedef boost::intmax_t static_sign_signed_type;
+ typedef boost::intmax_t static_sign_unsigned_type;
+
+ template <static_sign_signed_type X>
+ struct static_signed_sign
+ : integral_constant<static_sign_signed_type, X == 0 ? 0 : (X < 0 ? -1 : 1)>
+ {
+ };
+
+ template <static_sign_unsigned_type X>
+ struct static_unsigned_sign
+ : integral_constant<static_sign_unsigned_type, X == 0 ? 0 : (X < 0 ? -1 : 1)>
+ {
+ };
+
+}
+}
+
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk