libstdc++
tr2/ratio
Go to the documentation of this file.
00001 // TR2 <ratio> -*- C++ -*-
00002 
00003 // Copyright (C) 2010, 2011 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 3, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 /** @file tr2/ratio
00026  *  This is a TR2 C++ Library header.
00027  */
00028 
00029 #include <ratio>
00030 
00031 namespace std _GLIBCXX_VISIBILITY(default)
00032 {
00033 namespace tr2
00034 {
00035 _GLIBCXX_BEGIN_NAMESPACE_VERSION
00036 
00037   template<intmax_t _Pn, size_t _Bit,
00038          bool = _Bit < static_cast<size_t>
00039               (std::numeric_limits<intmax_t>::digits)>
00040     struct __safe_lshift
00041     { static const intmax_t __value = 0; };
00042 
00043     template<intmax_t _Pn, size_t _Bit>
00044       struct __safe_lshift<_Pn, _Bit, true>
00045       { static const intmax_t __value = _Pn << _Bit; };
00046 
00047   /// Add binary prefixes (IEC 60027-2 A.2 and ISO/IEC 80000).
00048   typedef ratio<__safe_lshift<1, 10>::__value, 1> kibi;
00049   typedef ratio<__safe_lshift<1, 20>::__value, 1> mebi;
00050   typedef ratio<__safe_lshift<1, 30>::__value, 1> gibi;
00051   typedef ratio<__safe_lshift<1, 40>::__value, 1> tebi;
00052   typedef ratio<__safe_lshift<1, 50>::__value, 1> pebi;
00053   typedef ratio<__safe_lshift<1, 60>::__value, 1> exbi;
00054   //typedef ratio<__safe_lshift<1, 70>::__value, 1> zebi;
00055   //typedef ratio<__safe_lshift<1, 80>::__value, 1> yobi;
00056 
00057 _GLIBCXX_END_NAMESPACE_VERSION
00058 }
00059 }