os/ossrv/ossrv_pub/boost_apis/boost/numeric/interval/policies.hpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /* Boost interval/policies.hpp template implementation file
     2  *
     3  * Copyright 2003 Guillaume Melquiond
     4  *
     5  * Distributed under the Boost Software License, Version 1.0.
     6  * (See accompanying file LICENSE_1_0.txt or
     7  * copy at http://www.boost.org/LICENSE_1_0.txt)
     8  */
     9 
    10 #ifndef BOOST_NUMERIC_INTERVAL_POLICIES_HPP
    11 #define BOOST_NUMERIC_INTERVAL_POLICIES_HPP
    12 
    13 #include <boost/numeric/interval/interval.hpp>
    14 
    15 namespace boost {
    16 namespace numeric {
    17 namespace interval_lib {
    18 
    19 /*
    20  * policies class
    21  */
    22 
    23 template<class Rounding, class Checking>
    24 struct policies
    25 {
    26   typedef Rounding rounding;
    27   typedef Checking checking;
    28 };
    29 
    30 /*
    31  * policies switching classes
    32  */
    33 
    34 template<class OldInterval, class NewRounding>
    35 class change_rounding
    36 {
    37   typedef typename OldInterval::base_type T;
    38   typedef typename OldInterval::traits_type p;
    39   typedef typename p::checking checking;
    40 public:
    41   typedef interval<T, policies<NewRounding, checking> > type;
    42 };
    43 
    44 template<class OldInterval, class NewChecking>
    45 class change_checking
    46 {
    47   typedef typename OldInterval::base_type T;
    48   typedef typename OldInterval::traits_type p;
    49   typedef typename p::rounding rounding;
    50 public:
    51   typedef interval<T, policies<rounding, NewChecking> > type;
    52 };
    53 
    54 /*
    55  * Protect / unprotect: control whether the rounding mode is set/reset
    56  * at each operation, rather than once and for all.
    57  */
    58 
    59 template<class OldInterval>
    60 class unprotect
    61 {
    62   typedef typename OldInterval::base_type T;
    63   typedef typename OldInterval::traits_type p;
    64   typedef typename p::rounding r;
    65   typedef typename r::unprotected_rounding newRounding;
    66 public:
    67   typedef typename change_rounding<OldInterval, newRounding>::type type;
    68 };
    69 
    70 } // namespace interval_lib
    71 } // namespace numeric
    72 } // namespace boost
    73 
    74 
    75 #endif // BOOST_NUMERIC_INTERVAL_POLICIES_HPP