$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r84128 - in sandbox/chrono_date/boost/chrono/date: . detail
From: vicente.botet_at_[hidden]
Date: 2013-05-03 16:03:27
Author: viboes
Date: 2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
New Revision: 84128
URL: http://svn.boost.org/trac/boost/changeset/84128
Log:
Date: refactoring; Addeed more constexpr+noexcept.
Added:
   sandbox/chrono_date/boost/chrono/date/detail/bounded.hpp   (contents, props changed)
Text files modified: 
   sandbox/chrono_date/boost/chrono/date/compressed_tuple.hpp |     2                                         
   sandbox/chrono_date/boost/chrono/date/config.hpp           |    10 +-                                      
   sandbox/chrono_date/boost/chrono/date/date_durations.hpp   |    28 ++++++-                                 
   sandbox/chrono_date/boost/chrono/date/date_io.hpp          |    16 +++-                                    
   sandbox/chrono_date/boost/chrono/date/day.hpp              |    98 +++--------------------------           
   sandbox/chrono_date/boost/chrono/date/day_of_year.hpp      |    88 ++------------------------              
   sandbox/chrono_date/boost/chrono/date/days_date.hpp        |    76 ++++++++++++++---------                 
   sandbox/chrono_date/boost/chrono/date/detail/helpers.hpp   |     2                                         
   sandbox/chrono_date/boost/chrono/date/exceptions.hpp       |     4                                         
   sandbox/chrono_date/boost/chrono/date/month.hpp            |   129 ++++++++++----------------------------- 
   sandbox/chrono_date/boost/chrono/date/month_nth.hpp        |    15 ++--                                    
   sandbox/chrono_date/boost/chrono/date/no_check.hpp         |     4                                         
   sandbox/chrono_date/boost/chrono/date/nth.hpp              |    84 +++++++++----------------               
   sandbox/chrono_date/boost/chrono/date/nth_week.hpp         |    76 +++++-----------------                  
   sandbox/chrono_date/boost/chrono/date/nth_weekday.hpp      |    34 +++++----                               
   sandbox/chrono_date/boost/chrono/date/tuples.hpp           |     7 +                                       
   sandbox/chrono_date/boost/chrono/date/week.hpp             |    80 +++---------------------                
   sandbox/chrono_date/boost/chrono/date/weekday.hpp          |   124 ++++++++++++--------------------------  
   sandbox/chrono_date/boost/chrono/date/year.hpp             |    96 +++++-----------------------            
   sandbox/chrono_date/boost/chrono/date/ymd_date.hpp         |    44 ++++++------                            
   20 files changed, 319 insertions(+), 698 deletions(-)
Modified: sandbox/chrono_date/boost/chrono/date/compressed_tuple.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/compressed_tuple.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/compressed_tuple.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -6,7 +6,7 @@
 //  http://www.boost.org/LICENSE_1_0.txt).
 
 #ifndef BOOST_COMPRESSED_TUPLE_HPP
-#define BOOST_CHRONO_DATE_MONTH_NTH_HPP
+#define BOOST_COMPRESSED_TUPLE_HPP
 
 #include <boost/cstdint.hpp>
 
Modified: sandbox/chrono_date/boost/chrono/date/config.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/config.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/config.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -11,12 +11,12 @@
 #include <boost/chrono/config.hpp>
 
 
-// 1 => days +ymd +leap
+// 1 => days + ymd + leap
 // 2 => days
-// 3 => ymd +leap
-// 4 => ydoy +leap
+// 3 => ymd + leap
+// 4 => ydoy + leap
 #ifndef BOOST_CHRONO_DATE_DATE_DESIGN
-#define BOOST_CHRONO_DATE_DATE_DESIGN 4
+#define BOOST_CHRONO_DATE_DATE_DESIGN 2
 #endif
 
 // 1 => days +ymd +leap
@@ -29,7 +29,7 @@
 // 2 => days
 // 3 => ymd +leap
 #ifndef BOOST_CHRONO_DATE_REL_DATE_DESIGN
-#define BOOST_CHRONO_DATE_REL_DATE_DESIGN 2
+#define BOOST_CHRONO_DATE_REL_DATE_DESIGN 3
 #endif
 
 
Modified: sandbox/chrono_date/boost/chrono/date/date_durations.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/date_durations.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/date_durations.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -36,13 +36,22 @@
     /**
      * A duration counting weeks.
      */
-    typedef duration<boost::int_least32_t, boost::ratio<7 * 86400> > weeks;
-    typedef duration<boost::int_least32_t, boost::ratio<2629746> >
-        average_months;
-    typedef duration<boost::int_least32_t, boost::ratio<31556952> >
+    typedef duration<boost::int_least32_t, ratio_multiply<days::period, ratio<7> > > weeks;
+    /**
+     * A duration counting eras = 400 years.
+     */
+    typedef duration<boost::int_least32_t, ratio_multiply<days::period, ratio<146097> > >
+        eras;
+    /**
+     * A duration counting average years = eras / 400.
+     */
+    typedef duration<boost::int_least32_t, ratio_divide<eras::period, ratio<400> > >
         average_years;
-    //typedef duration<boost::int_least32_t, boost::ratio<400 * 31556952> >
-    //    _400_years;
+    /**
+     * A duration counting average months = average_years / 12.
+     */
+    typedef duration<boost::int_least32_t, ratio_divide<average_years::period, ratio<12> > >
+        average_months;
 
 
 //    /**
@@ -303,7 +312,14 @@
       };
     }
 
+    /**
+     * A independent duration counting of months.
+     */
     typedef detail::duration_type<int32_t, 1> months;
+
+    /**
+     * A independent duration counting of years.
+     */
     typedef detail::duration_type<int32_t, 2> years;
 
   } // chrono
Modified: sandbox/chrono_date/boost/chrono/date/date_io.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/date_io.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/date_io.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -250,7 +250,9 @@
       if (ok)
       {
         std::ios_base::iostate err = std::ios_base::goodbit;
-        try
+#ifndef BOOST_NO_EXCEPTIONS
+        try // BOOST_NO_EXCEPTIONS protected
+#endif
         {
           const std::time_get<charT>& tg =
               std::use_facet<std::time_get<charT> >(is.getloc());
@@ -274,10 +276,12 @@
                 = Date(year(t.tm_year + 1900), month(t.tm_mon + 1), day(t.tm_mday));
           }
         }
-        catch (...)
+#ifndef BOOST_NO_EXCEPTIONS
+        catch (...) // BOOST_NO_EXCEPTIONS protected
         {
           err |= std::ios_base::badbit | std::ios_base::failbit;
         }
+#endif
         is.setstate(err);
       }
       return is;
@@ -315,7 +319,9 @@
       if (ok)
       {
         bool failed;
-        try
+#ifndef BOOST_NO_EXCEPTIONS
+        try // BOOST_NO_EXCEPTIONS protected
+#endif
         {
           const std::time_put<charT>& tp =
               std::use_facet<std::time_put<charT> >(os.getloc());
@@ -338,10 +344,12 @@
           }
           failed = tp.put(os, os, os.fill(), &t, pb, pe).failed();
         }
-        catch (...)
+#ifndef BOOST_NO_EXCEPTIONS
+        catch (...) // BOOST_NO_EXCEPTIONS protected
         {
           failed = true;
         }
+#endif
         if (failed)
         {
           os.setstate(std::ios_base::failbit | std::ios_base::badbit);
Modified: sandbox/chrono_date/boost/chrono/date/day.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/day.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/day.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -6,105 +6,31 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#ifndef BOOST_CHRONO_DATE_DATE_DAY_HPP
-#define BOOST_CHRONO_DATE_DATE_DAY_HPP
+#ifndef BOOST_CHRONO_DATE_DAY_HPP
+#define BOOST_CHRONO_DATE_DAY_HPP
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/no_check.hpp>
-#include <boost/chrono/date/exceptions.hpp>
-#include <boost/chrono/date/detail/to_string.hpp>
-
+#include <boost/chrono/date/detail/bounded.hpp>
 
 namespace boost
 {
   namespace chrono
   {
-
     /**
-     * The class @c day is used to specify the day of the month when constructing dates.
+     * day tag
+     */
+    struct day_tag {};
+    /**
+     * The class @c day is used to specify the day of the month when constructing dates. Its range is [1,31].
      */
-    class day
-    {
-    public:
-      typedef int_least8_t rep;
-      static const rep last_=31;
-      static const rep first_=1;
-      static const std::size_t size=last_-first_+1; // :5 bits
-
-      /**
-       * @Effects: Constructs an object of class @c day by storing @c d.
-       * @Postconditions: <c>value() == d && is_valid()</c>.
-       * @Throws: if @c d is outside of the range [1, 31], throws an exception of type @c bad_date.
-       */
-      explicit day(rep d)
-      : value_(d)
-      {
-        if (!is_valid())
-        {
-          throw bad_date("day " + boost::chrono::to_string(int(d)) + " is out of range");
-        }
-      }
-
-      /**
-       * @Effects: Constructs an object of class @c day by storing @c d.
-       * @Postconditions: <c>value() == d</c>.
-       * @Note This function doesn't check the parameters validity.
-       * It is up to the user to provide a valid ones.
-       */
-      BOOST_CONSTEXPR day(rep d,no_check_t) BOOST_NOEXCEPT
-      : value_(d)
-      {}
-      /**
-       * @Return if the stored value is a valid one.
-       */
-      bool is_valid() const BOOST_NOEXCEPT
-      {
-        return (first_ <= value_ && value_ <= last_);
-      }
-      /**
-       * @Returns: the underlying value of that day.
-       */
-      operator rep() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * @Returns: the underlying value of that day.
-       */
-      rep value() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * @Returns: the min valid value for a day of a month.
-       */
-      static BOOST_CONSTEXPR day min BOOST_PREVENT_MACRO_SUBSTITUTION ()
-      {
-          return day(first_,no_check);
-      }
-      /**
-       * @Returns: the first day of a month.
-       */
-      static BOOST_CONSTEXPR day first()
-      {
-          return day(first_,no_check);
-      }
-      /**
-       * @Returns: the max valid value for a day of a month.
-       */
-      static BOOST_CONSTEXPR day max BOOST_PREVENT_MACRO_SUBSTITUTION ()
-      {
-          return day(last_,no_check);
-      }
-    private:
-      rep value_;
-    };
+    typedef bounded<day_tag, 1, 31, int_least8_t> day;
 
+    /**
+     * synonym of day.
+     */
     typedef day day_of_month;
 
   } // chrono
-
 } // boost
 
 #endif  // header
Modified: sandbox/chrono_date/boost/chrono/date/day_of_year.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/day_of_year.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/day_of_year.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -10,10 +10,7 @@
 
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/no_check.hpp>
-#include <boost/chrono/date/exceptions.hpp>
-#include <boost/chrono/date/detail/to_string.hpp>
+#include <boost/chrono/date/detail/bounded.hpp>
 
 namespace boost
 {
@@ -21,83 +18,14 @@
   {
 
     /**
-     * The class day_of_year is used to specify the day of the year when constructing a date.
+     * day_of_year tag
      */
-    class day_of_year
-    {
-    public:
-      typedef int_least16_t rep;
-      static const rep last_=366;
-      static const rep first_=1;
-      static const std::size_t size=last_-first_+1; // :9 bits
-
-      /**
-       * @Effects: Constructs an object of class @c day_of_year by storing @c d.
-       * @Postconditions: <c>value() == d && is_valid()</c>.
-       * @Throws: if @c d is outside of the range [1, 366], throws an exception of type @c bad_date.
-       */
-      explicit day_of_year(rep d)
-          : value_(d)
-          {
-            if (!is_valid())
-            {
-              throw bad_date("day_of_year " + boost::chrono::to_string(d) + " is out of range");
-            }
-          }
-      /**
-       * @Effects: Constructs an object of class @c day_of_year by storing @c d.
-       * @Postconditions: <c>value() == d</c>.
-       * @Note This function doesn't check the parameters validity.
-       * It is up to the user to provide a valid ones.
-       */
-      BOOST_CONSTEXPR day_of_year(rep d,no_check_t) BOOST_NOEXCEPT
-      : value_(d)
-      {}
-      /**
-       * @Return if the stored value is a valid one, i.e. in the range [1,366].
-       */
-      bool is_valid() const BOOST_NOEXCEPT
-      {
-        return (first_ <= value_ && value_ <= last_);
-      }
-      /**
-       * @Returns: the underlying value of that day of year.
-       */
-      operator rep() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * @Returns: the underlying value of that day of year.
-       */
-      rep value() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * @Returns: the min valid value for a day of a year.
-       */
-      static BOOST_CONSTEXPR day_of_year min BOOST_PREVENT_MACRO_SUBSTITUTION ()
-      {
-          return day_of_year(first_,no_check);
-      }
-      /**
-       * @Returns: the first day of a month.
-       */
-      static BOOST_CONSTEXPR day_of_year first()
-      {
-          return day_of_year(first_,no_check);
-      }
-      /**
-       * @Returns: the max valid value for a day of a year.
-       */
-      static BOOST_CONSTEXPR day_of_year max BOOST_PREVENT_MACRO_SUBSTITUTION ()
-      {
-        return day_of_year(last_,no_check);
-      }
-    private:
-      rep value_;
-    };
+    struct day_of_year_tag {};
+
+    /**
+     * The class day_of_year is used to specify the day of the year when constructing a date. Its range is [1,366].
+     */
+    typedef bounded<day_of_year_tag, 1, 366, int_least16_t> day_of_year;
 
   } // chrono
 
Modified: sandbox/chrono_date/boost/chrono/date/days_date.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/days_date.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/days_date.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -25,6 +25,7 @@
 #include <boost/chrono/date/conversions.hpp>
 #include <boost/chrono/date/optional_date.hpp>
 #include <boost/chrono/date/is_date.hpp>
+#include <boost/throw_exception.hpp>
 
 namespace boost
 {
@@ -58,15 +59,18 @@
        * Else constructs a @c days_date for which <c>get_year() == y && get_month() == m && get_day() == d</c>.
        * @Throws bad_date if the specified days_date is invalid.
        */
-      days_date(chrono::year y, chrono::month m, chrono::day d);
+      days_date(year y, month m, day d);
+      //days_date(year::rep y, month m, day d);
+      //days_date(year y, month::rep m, day d);
+      //days_date(year y, month m, day::rep d);
+
       /**
        * @Effect Constructs a @c days_date constructor from @c year, @c month, @c day stored in the arguments as follows:
        * Constructs a @c days_date so that <c>get_year() == y && get_month() == m && get_day() == d</c>.
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide a valid ones.
        */
-      days_date(year::rep y, month::rep m, day::rep d, no_check_t)
-BOOST_NOEXCEPT      ;
+      days_date(year::rep y, month::rep m, day::rep d, no_check_t) BOOST_NOEXCEPT;
       /**
        * @Effect Constructs a @c days_date using the @c year, @c month_day stored in the arguments as follows:
        * If the value stored in @c md is outside the range of valid dates for the year @c y,
@@ -76,14 +80,14 @@
        * @Throws @c bad_date if the specified @c days_date is invalid.
        * @Note This constructor can be more efficient as the @c month_day is already valid.
        */
-      days_date(chrono::year y, chrono::month_day md);
+      days_date(year y, month_day md);
       /**
        * @Effect Constructs a @c days_date using the @c year, @c month_day stored in the arguments as follows:
        * Constructs a @c days_date for which <c>get_year() == y && get_month() == md.get_month() && get_day() == md.get_day()</c>.
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide a valid ones.
        */
-      days_date(chrono::year::rep, chrono::month_day, no_check_t) BOOST_NOEXCEPT;
+      days_date(year::rep, month_day, no_check_t) BOOST_NOEXCEPT;
 
       /**
        * @Effect Constructs a @c days_date using the @c year, @c day_of_year stored in the arguments as follows:
@@ -93,7 +97,7 @@
        * @Throws @c bad_date if the specified @c days_date is invalid.
        * @Note This constructor can be more efficient as the check is simpler.
        */
-      days_date(chrono::year y, chrono::day_of_year doy);
+      days_date(year y, day_of_year doy);
       /**
        * @Effect Constructs a days_date using the year, day_of_year stored in the arguments as follows:
        * Constructs a days_date for which days_since_epoch() == y.days_since_epoch()+doy.value()
@@ -107,38 +111,50 @@
        * <c>days_since_epoch() == ds.count()</c>.
        * @Throws @bad_date if the days is not in the range [11322,23947853].
        */
-      explicit days_date(chrono::days d)
+      explicit days_date(days d)
       : x_(d.count())
       {
         if (!is_valid())
         {
-          throw bad_date("days " + boost::chrono::to_string(d.count()) + " is out of range");
+          throw_exception( bad_date("days " + to_string(d.count()) + " is out of range") );
         }
       }
 
       /**
        * Unchecked constructor from @c days
-       * @Effect Constructs a @c days_date using the @c days given as parameter so that:
-       * <c>days_since_epoch() == ds.count()</c>.
+       * @Effect Constructs a @c days_date using the @c x.count() days given as parameter so that:
+       * <c>days_since_epoch() == x.count()</c>.
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide a valid ones.
        */
-      days_date(days::rep x, no_check_t) BOOST_NOEXCEPT
-      : x_(x)
+      days_date(days d, no_check_t) BOOST_NOEXCEPT
+      : x_(d.count())
       {
       }
       /**
-       * @Effect Constructs a @c days_date constructor from @c year, @c month, @c day stored in the arguments as follows:
-       * Constructs a @c days_date so that <c>get_year() == y @@  get_month() = m &&  get_day() == d</c>.
+       * Unchecked constructor from @c days::rep
+       * @Effect Constructs a @c days_date using the @c x days given as parameter so that:
+       * <c>days_since_epoch() == x.count()</c>.
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide a valid ones.
        */
-      days_date(days::rep x, year::rep, month::rep, day::rep, bool, no_check_t) BOOST_NOEXCEPT
+      days_date(days::rep x, no_check_t) BOOST_NOEXCEPT
       : x_(x)
       {
       }
       /**
        * @Effect Constructs a @c days_date constructor from @c year, @c month, @c day stored in the arguments as follows:
+       * Constructs a @c days_date so that <c>get_year() == y &&  get_month() = m &&  get_day() == d</c>.
+       * @Note This function doesn't check the parameters validity.
+       * It is up to the user to provide a valid ones.
+       */
+//      days_date(days::rep x, year::rep, month::rep, day::rep, bool, no_check_t) BOOST_NOEXCEPT
+//      : x_(x)
+//      {
+//      }
+      /**
+       * @Effect Constructs a @c days_date constructor from @c year::rep, @c month::rep, @c day::rep and
+       * if the year is leap stored in the arguments as follows:
        * Constructs a @c days_date so that <c>get_year() == y && get_month() = m && get_day() == d</c>.
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide a valid ones.
@@ -177,17 +193,17 @@
        * an exception of type @c bad_date.
        *
        */
-      explicit days_date(boost::chrono::system_clock::time_point tp);
+      explicit days_date(system_clock::time_point tp);
       /**
-       * @Returns: A chrono::system_clock::time_point which represents the @c days_date
+       * @Returns: A system_clock::time_point which represents the @c days_date
        * referred to by *this at 00:00:00 UTC.
        *
        * @Throws: If the conversion to @c tp overflows the range of
-       * boost::chrono::system_clock::time_point, throws an exception of type @c bad_date.
+       * system_clock::time_point, throws an exception of type @c bad_date.
        *
        */
       // explicit
-      operator boost::chrono::system_clock::time_point () const;
+      operator system_clock::time_point () const;
 
 
       // Observers
@@ -208,25 +224,25 @@
       }
 
       /**
-       * Returns: <c>chrono::day(d_,no_check)</c>.
+       * Returns: <c>day(d_,no_check)</c>.
        */
-      chrono::day get_day() const BOOST_NOEXCEPT
+      day get_day() const BOOST_NOEXCEPT
       {
-        return chrono::day(day_from_day_number(),no_check);
+        return day(day_from_day_number(),no_check);
       }
       /**
-       * Returns: <c>chrono::month(m_,no_check)</c>.
+       * Returns: <c>month(m_,no_check)</c>.
        */
-      chrono::month get_month() const BOOST_NOEXCEPT
+      month get_month() const BOOST_NOEXCEPT
       {
-        return chrono::month(month_from_day_number(),no_check);
+        return month(month_from_day_number(),no_check);
       }
       /**
-       * Returns: <c>chrono::year(y_,no_check)</c>.
+       * Returns: <c>year(y_,no_check)</c>.
        */
-      chrono::year get_year() const BOOST_NOEXCEPT
+      year get_year() const BOOST_NOEXCEPT
       {
-        return chrono::year(year_from_day_number(),no_check);
+        return year(year_from_day_number(),no_check);
       }
       /**
        * Returns: @c true if @c year() is a leap year, and @c false otherwise.
@@ -252,9 +268,9 @@
        * @Returns: A weekday constructed with an int corresponding to *this
        * days_date's day of the week (a value in the range of [0 - 6], 0 is Sunday).
        */
-      chrono::weekday get_weekday() const BOOST_NOEXCEPT
+      weekday get_weekday() const BOOST_NOEXCEPT
       {
-        return chrono::weekday((x_ + 1) % weekday::size, no_check);
+        return weekday((x_ + 1) % weekday::size, no_check);
       }
 
       // Days Based Arithmetic
Added: sandbox/chrono_date/boost/chrono/date/detail/bounded.hpp
==============================================================================
--- (empty file)
+++ sandbox/chrono_date/boost/chrono/date/detail/bounded.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -0,0 +1,134 @@
+//  date
+//
+//  (C) Copyright Howard Hinnant
+//  Copyright 2013 Vicente J. Botet Escriba
+//  Use, modification and distribution are subject to 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).
+
+#ifndef BOOST_CHRONO_DATE_BOUNDED_HPP
+#define BOOST_CHRONO_DATE_BOUNDED_HPP
+
+#include <boost/chrono/config.hpp>
+#include <boost/chrono/date/no_check.hpp>
+#include <boost/chrono/date/exceptions.hpp>
+#include <boost/chrono/date/detail/to_string.hpp>
+#include <boost/throw_exception.hpp>
+#include <exception>
+
+
+namespace boost
+{
+  namespace chrono
+  {
+
+    /**
+     * The class @c bounded is used to specify an opaque wrapper around integral type.
+     */
+    template <typename Tag, int first_, int last_, typename T=int, typename IT=int>
+    class bounded
+    {
+    public:
+      typedef T rep;
+      typedef IT irep;
+      BOOST_STATIC_CONSTEXPR std::size_t size=last_-first_+1; // :5 bits
+
+    private:
+      static BOOST_CONSTEXPR bool is_valid_(irep v) BOOST_NOEXCEPT
+      {
+        return (first_ <= v && v <= last_);
+      }
+    public:
+
+      /**
+       * @Effects: Constructs an object of class @c bounded by storing @c d.
+       * @Postconditions: <c>value() == d && is_valid()</c>.
+       * @Throws: if @c d is outside of the range [first, last], throws an exception of type @c std::logic_error.
+       */
+
+#ifndef  BOOST_NO_CXX11_CONSTEXPR
+      BOOST_CONSTEXPR explicit bounded(irep d)
+      : value_(
+          is_valid_(d)
+          ? d
+          : throw std::logic_error("bounded " + boost::chrono::to_string(int(d)) + " is out of range")
+        )
+      {}
+#else
+      BOOST_CONSTEXPR explicit bounded(irep d)
+      : value_(d)
+      {
+        if (!is_valid_(d))
+          throw std::logic_error("bounded " + boost::chrono::to_string(int(d)) + " is out of range");
+      }
+#endif
+      /**
+       * @Effects: Constructs an object of class @c bounded by storing @c d.
+       * @Postconditions: <c>value() == d</c>.
+       * @Note This function doesn't check the parameters validity.
+       * It is up to the user to provide a valid ones.
+       */
+      BOOST_CONSTEXPR bounded(irep d,no_check_t) BOOST_NOEXCEPT
+      : value_(d)
+      {}
+      /**
+       * @Return if the stored value is a valid one.
+       */
+      BOOST_CONSTEXPR bool is_valid() const BOOST_NOEXCEPT
+      {
+        return is_valid_(value_);
+      }
+      /**
+       * @Requires @c is_valid()
+       * @Returns the underlying value of that bounded.
+       */
+      BOOST_CONSTEXPR operator irep() const BOOST_NOEXCEPT
+      {
+        return value_;
+      }
+      /**
+       * @Requires @c is_valid()
+       * @Returns: the underlying value of that bounded.
+       */
+      BOOST_CONSTEXPR irep value() const BOOST_NOEXCEPT
+      {
+        return value_;
+      }
+      /**
+       * @Returns: the min valid value for a bounded of a month.
+       */
+      static BOOST_CONSTEXPR bounded min BOOST_PREVENT_MACRO_SUBSTITUTION () BOOST_NOEXCEPT
+      {
+          return bounded(first_,no_check);
+      }
+      /**
+       * @Returns: the max valid value for a bounded of a month.
+       */
+      static BOOST_CONSTEXPR bounded max BOOST_PREVENT_MACRO_SUBSTITUTION () BOOST_NOEXCEPT
+      {
+          return bounded(last_,no_check);
+      }
+      /**
+       * @Returns: the first bounded.
+       */
+      static BOOST_CONSTEXPR bounded first() BOOST_NOEXCEPT
+      {
+          return bounded(first_,no_check);
+      }
+      /**
+       * @Returns: the first bounded.
+       */
+      static BOOST_CONSTEXPR bounded last() BOOST_NOEXCEPT
+      {
+          return bounded(last_,no_check);
+      }
+    private:
+      rep value_;
+    };
+
+
+  } // chrono
+
+} // boost
+
+#endif  // header
Modified: sandbox/chrono_date/boost/chrono/date/detail/helpers.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/detail/helpers.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/detail/helpers.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -54,7 +54,7 @@
     day_of_year_rep month_day_to_day_of_year(bool, month_rep, day_rep)
 BOOST_NOEXCEPT  ;
 
-} // chrono
+  } // chrono
 } // boost
 
 #endif
Modified: sandbox/chrono_date/boost/chrono/date/exceptions.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/exceptions.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/exceptions.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -6,8 +6,8 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#ifndef BOOST_CHRONO_DATE_DATE_EXCEPTIONS_HPP
-#define BOOST_CHRONO_DATE_DATE_EXCEPTIONS_HPP
+#ifndef BOOST_CHRONO_DATE_EXCEPTIONS_HPP
+#define BOOST_CHRONO_DATE_EXCEPTIONS_HPP
 
 
 #include <exception>
Modified: sandbox/chrono_date/boost/chrono/date/month.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/month.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/month.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -6,14 +6,12 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#ifndef BOOST_CHRONO_DATE_DATE_MONTH_HPP
-#define BOOST_CHRONO_DATE_DATE_MONTH_HPP
+#ifndef BOOST_CHRONO_DATE_MONTH_HPP
+#define BOOST_CHRONO_DATE_MONTH_HPP
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/no_check.hpp>
-#include <boost/chrono/date/exceptions.hpp>
-#include <boost/chrono/date/detail/to_string.hpp>
+#include <boost/chrono/date/detail/bounded.hpp>
+
 
 namespace boost
 {
@@ -21,95 +19,31 @@
   {
 
     /**
-     * The class @c month is used to specify the month of the year when constructing a date.
+     * month tag
      */
-    class month
-    {
-    public:
-      typedef int_least8_t rep;
-      static const rep last_ = 12;
-      static const rep first_ = 1;
-      static const std::size_t size = last_ - first_ + 1; // 4 bits
-
-      /**
-       * @Effects: Constructs an object of class @c month by storing @c m.
-       * @Postconditions: <c>value() == m && is_valid()</c>.
-       * @Throws: if @c m is outside of the range [1, 12], throws an exception of type @c bad_date.
-       */
-      explicit month(rep v) :
-        value_(v)
-      {
-        if (!(is_valid()))
-        {
-          throw bad_date("month " + boost::chrono::to_string(int(v))
-              + " is out of range");
-        }
-      }
-      /**
-       * @Effects: Constructs an object of class @c month by storing @c m.
-       * @Postconditions: value() == m.
-       * @Note This function doesn't check the parameters validity.
-       * It is up to the user to provide a valid ones.
-       */
-      BOOST_CONSTEXPR explicit month(rep m, no_check_t) BOOST_NOEXCEPT:
-        value_(m)
-      {
-      }
-
-      /**
-       * @Return if the stored value is a valid one, i.e. on the range [1, 12].
-       */
-      bool is_valid() const BOOST_NOEXCEPT
-      {
-        return (first_ <= value_ && value_ <= last_);
-      }
-
-      /**
-       * @Returns: the value of the stored int.
-       */
-      operator rep() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * @Returns: the value of the stored int.
-       */
-      rep value() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      month next() const BOOST_NOEXCEPT
-      {
-        return month(((value_-first_+1)%size)+first_,no_check);
-      }
-      month prev() BOOST_NOEXCEPT
-      {
-        return month(((value_-first_+size-1)%size)+first_,no_check);
-      }
-      static BOOST_CONSTEXPR month first() BOOST_NOEXCEPT
-      {
-        return month(first_,no_check);
-      }
-      static BOOST_CONSTEXPR month last() BOOST_NOEXCEPT
-      {
-        return month(last_,no_check);
-      }
-      static BOOST_CONSTEXPR month min BOOST_PREVENT_MACRO_SUBSTITUTION () BOOST_NOEXCEPT
-      {
-        return month(first_,no_check);
-      }
-      static BOOST_CONSTEXPR month max BOOST_PREVENT_MACRO_SUBSTITUTION () BOOST_NOEXCEPT
-      {
-        return month(last_,no_check);
-      }
-
-      //      friend class date;
-      //      friend class rel_date;
-    private:
-      rep value_;
-
-    };
+    struct month_tag {};
+    /**
+     * The class @c month is used to specify the month of the year when constructing a date.  Its range is [1,12].
+     */
+    typedef bounded<month_tag, 1, 12, int_least8_t> month;
 
+    /**
+     * month pseudo-literals.
+     */
+#ifndef  BOOST_NO_CXX11_CONSTEXPR
+    BOOST_CONSTEXPR_OR_CONST month jan(1, no_check);
+    BOOST_CONSTEXPR_OR_CONST month feb(2, no_check);
+    BOOST_CONSTEXPR_OR_CONST month mar(3, no_check);
+    BOOST_CONSTEXPR_OR_CONST month apr(4, no_check);
+    BOOST_CONSTEXPR_OR_CONST month may(5, no_check);
+    BOOST_CONSTEXPR_OR_CONST month jun(6, no_check);
+    BOOST_CONSTEXPR_OR_CONST month jul(7, no_check);
+    BOOST_CONSTEXPR_OR_CONST month aug(8, no_check);
+    BOOST_CONSTEXPR_OR_CONST month sep(9, no_check);
+    BOOST_CONSTEXPR_OR_CONST month oct(10, no_check);
+    BOOST_CONSTEXPR_OR_CONST month nov(11, no_check);
+    BOOST_CONSTEXPR_OR_CONST month dec(12, no_check);
+#else
     extern const month jan;
     extern const month feb;
     extern const month mar;
@@ -123,6 +57,13 @@
     extern const month nov;
     extern const month dec;
 
+#endif
+
+    /**
+     * Overload for month conversion to string.
+     * @param v the @c month
+     * @return the string representing the month.
+     */
     inline std::string to_string(month v) {
       switch (v) {
       case 1: return "Jan";
@@ -137,7 +78,7 @@
       case 10: return "Oct";
       case 11: return "Nov";
       case 12: return "Dec";
-      default: throw bad_date("month " + boost::chrono::to_string(unsigned(v.value())) + " is out of range");
+      default: throw_exception( bad_date("month " + boost::chrono::to_string(unsigned(v.value())) + " is out of range") );
 
       }
     }
Modified: sandbox/chrono_date/boost/chrono/date/month_nth.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/month_nth.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/month_nth.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -15,6 +15,7 @@
 #include <boost/chrono/date/exceptions.hpp>
 #include <boost/chrono/date/detail/to_string.hpp>
 #include <boost/chrono/date/detail/helpers.hpp>
+#include <boost/throw_exception.hpp>
 
 namespace boost
 {
@@ -34,24 +35,24 @@
        * @Postconditions: get_month() == m && get_nth() == d && is_valid().
        * @Throws: if d is outside of the valid range of days of month @c m, throws an exception of type bad_date.
        */
-      month_nth(month m, nth d) BOOST_NOEXCEPT
+      month_nth(month m, nth d)
       : m_(m),
       d_(d)
       {
         if (!(d_<= days_in_month(1,m_)))
         {
-          throw bad_date("nth " + boost::chrono::to_string(int(d)) + "is out of range respect to month" + boost::chrono::to_string(m));
+          throw_exception( bad_date("nth " + boost::chrono::to_string(int(d)) + "is out of range respect to month" + boost::chrono::to_string(m)) );
         }
       }
       /**
        * @Effects: Constructs an object of class @c month_nth by storing @c m and @c d.
        * @Postconditions: get_month() == m && get_nth() == d.
        * @Note This function doesn't check the parameters validity.
-       * It is up to the user to provide a valid ones.
+       * It is up to the user to provide the valid ones.
        */
       month_nth(month::rep m, nth::rep d, no_check_t) BOOST_NOEXCEPT
-      : m_(m),
-      d_(d)
+      : m_(m, no_check),
+      d_(d, no_check)
       {
       }
       /**
@@ -111,8 +112,8 @@
       return month_nth(m, nth(5,no_check));
     }
     /**
-     * @Return a the @c month_nth with the associated parameters.
-     * @Throws if d is outside of the valid range of days of month @c m, throws an exception of type bad_date.
+     * @Returns the @c month_nth with the associated parameters.
+     * @Throws if @c d is outside of the valid range of days of month @c m, throws an exception of type bad_date.
      */
     inline month_nth operator/(nth d, month m)
 BOOST_NOEXCEPT  {
Modified: sandbox/chrono_date/boost/chrono/date/no_check.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/no_check.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/no_check.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -5,8 +5,8 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#ifndef BOOST_CHRONO_DATE_DATE_NO_CHECK_HPP
-#define BOOST_CHRONO_DATE_DATE_NO_CHECK_HPP
+#ifndef BOOST_CHRONO_DATE_NO_CHECK_HPP
+#define BOOST_CHRONO_DATE_NO_CHECK_HPP
 
 
 namespace boost
Modified: sandbox/chrono_date/boost/chrono/date/nth.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/nth.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/nth.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -10,84 +10,60 @@
 #define BOOST_CHRONO_DATE_NTH_HPP
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/no_check.hpp>
-#include <boost/chrono/date/exceptions.hpp>
-#include <boost/chrono/date/detail/to_string.hpp>
+#include <boost/chrono/date/detail/bounded.hpp>
+
 namespace boost
 {
   namespace chrono
   {
+    /**
+     * nth tag
+     */
+    struct nth_tag {};
 
     /**
      * The class nth is used to specify a small integral value that indicates the nth day of the month (example: last, 1st).
+     * Its range is [1, 6].
      */
-    class nth
+    class nth: public bounded<nth_tag, 1, 6, int_least8_t>
     {
-    public:
-      typedef int_least8_t rep;
-      static const rep not_applicable=7;
-      //static const rep not_applicable=-32;
-      static const rep last_=31;
-      static const rep first_=-32;
-      //static const rep last_=6;
-      //static const rep first_=1;
-      static const std::size_t size=last_-first_+1; // :3 bits
-
-      nth(rep s) BOOST_NOEXCEPT
-          : value_(s)
-      {
-        if (!is_valid())
-        {
-          throw bad_date("day " + boost::chrono::to_string(int(s)) + " is out of range");
-        }
-      }
-      nth(rep s, no_check_t) BOOST_NOEXCEPT
-          : value_(s)
-      {
-      }
+      typedef bounded<nth_tag, 1, 6, int_least8_t> base_type;
 
+    public:
+      BOOST_STATIC_CONSTEXPR rep not_applicable=7;
       /**
-       * @Return The nth stored component.
-       */
-      operator rep() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * @Return The nth stored component.
+       * @Effects: Constructs an object of class @c nth by storing @c s.
+       * Throws: if @c s is outside of the range [1, 6], throws an exception of type bad_date.
        */
-      rep value() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
+      BOOST_CONSTEXPR nth(irep s) : base_type(s)
+      {}
       /**
-       * @Return if the stored value is a valid one.
+       * @Effects: Constructs an object of class @c nth by storing @c s.
+       * @Note This function doesn't check the parameters validity.
+       * It is up to the user to provide a valid ones.
        */
-      bool is_valid() const BOOST_NOEXCEPT
-      {
-        return (first_ <= value_ && value_ <= last_);
-      }
-      bool is_not_applicable() const BOOST_NOEXCEPT
+      BOOST_CONSTEXPR nth(irep s, no_check_t) BOOST_NOEXCEPT
+          : base_type(s, no_check)
+      {}
+
+      BOOST_CONSTEXPR bool is_not_applicable() const BOOST_NOEXCEPT
       {
-        return value_==not_applicable;
+        return value()==not_applicable;
       }
-    private:
-      rep value_; // 3 bits if only valid up to _5th
     };
 
     struct last_t {};
-    const last_t last = {};
+    BOOST_CONSTEXPR_OR_CONST last_t last = {};
     struct _1st_t {};
-    const _1st_t _1st = {};
+    BOOST_CONSTEXPR_OR_CONST _1st_t _1st = {};
     struct _2nd_t {};
-    const _2nd_t _2nd = {};
+    BOOST_CONSTEXPR_OR_CONST _2nd_t _2nd = {};
     struct _3rd_t {};
-    const _3rd_t _3rd = {};
+    BOOST_CONSTEXPR_OR_CONST _3rd_t _3rd = {};
     struct _4th_t {};
-    const _4th_t _4th = {};
+    BOOST_CONSTEXPR_OR_CONST _4th_t _4th = {};
     struct _5th_t {};
-    const _5th_t _5th = {};
+    BOOST_CONSTEXPR_OR_CONST _5th_t _5th = {};
 
 
 
Modified: sandbox/chrono_date/boost/chrono/date/nth_week.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/nth_week.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/nth_week.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -11,88 +11,50 @@
 
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/no_check.hpp>
-#include <boost/chrono/date/exceptions.hpp>
-#include <boost/chrono/date/detail/to_string.hpp>
+#include <boost/chrono/date/detail/bounded.hpp>
 
 namespace boost
 {
   namespace chrono
   {
+    /**
+     * nth_week tag
+     */
+    struct nth_week_tag {};
 
     /**
-     * The class nth_week is used to specify a small integral value that indicates the nth week of the month (example: last_week, 1st_week).
+     * The class nth_week is used to specify a small integral value that indicates the nth week of the month
+     * (example: last_week, 1st_week).  Its range is [1,6].
      */
-    class nth_week
+    class nth_week : public bounded<nth_week_tag, 1, 6, int_least8_t>
     {
+      typedef bounded<nth_week_tag, 1, 6, int_least8_t> base_type;
+
     public:
-      typedef int_least8_t rep;
-      static const rep not_applicable=7;
-      static const rep last_=6;
-      static const rep first_=1;
-      static const std::size_t size=last_-first_+1; // :5 bits
+      BOOST_STATIC_CONSTEXPR rep not_applicable=7;
+      nth_week() : base_type(not_applicable) {}
 
       /**
        * @Effects: Constructs an object of class @c nth_week by storing @c s.
        * Throws: if @c s is outside of the range [1, 6], throws an exception of type bad_date.
        */
-      nth_week(rep s) : value_(s)
-      {
-        if (!is_valid())
-        {
-          throw bad_date("day " + boost::chrono::to_string(int(s)) + " is out of range");
-        }
-      }
+      nth_week(irep s) : base_type(s)
+      {}
       /**
        * @Effects: Constructs an object of class @c nth_week by storing @c s.
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide a valid ones.
        */
-      nth_week(rep s, no_check_t) BOOST_NOEXCEPT
-          : value_(s)
-      {
-      }
-      /**
-       * Implicit conversion to the representation.
-       *
-       * @Return The nth week stored component.
-       */
-      operator rep() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * @Return The nth stored component.
-       */
-      rep value() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
+      BOOST_CONSTEXPR nth_week(irep s, no_check_t) BOOST_NOEXCEPT
+          : base_type(s, no_check)
+      {}
 
-      /**
-       * @Return if the stored value is a valid one, i.e. in the range [1,6].
-       */
-      bool is_valid() const BOOST_NOEXCEPT
-      {
-        return (first_ <= value_ && value_ <= last_);
-      }
-      bool is_not_applicable() const BOOST_NOEXCEPT
+      BOOST_CONSTEXPR bool is_not_applicable() const BOOST_NOEXCEPT
       {
-        return value_==not_applicable;
+        return value()==not_applicable;
       }
-    private:
-      rep value_; // 3 bits if only valid up to _5th
     };
 
-//    extern const nth_week last_week;
-//    extern const nth_week _1st_week;
-//    extern const nth_week _2nd_week;
-//    extern const nth_week _3rd_week;
-//    extern const nth_week _4th_week;
-//    extern const nth_week _5th_week;
-
-
   } // chrono
 
 } // boost
Modified: sandbox/chrono_date/boost/chrono/date/nth_weekday.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/nth_weekday.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/nth_weekday.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -34,9 +34,8 @@
        * @param n the nth week
        * @param dow the day of the year
        * @Effects: Constructs a pair of nth-weekday.
-       * Throws: if nth.value() is outside of the range [1, 5], throws an exception of type bad_date.
        */
-      nth_weekday(nth_week n, weekday dow) BOOST_NOEXCEPT
+      BOOST_CONSTEXPR nth_weekday(nth_week n, weekday dow) BOOST_NOEXCEPT
       :
       n_(n),
       dow_(dow)
@@ -51,31 +50,31 @@
        * @Note This function doesn't check the parameters validity.
        * It is up to the user to provide a valid ones.
        */
-      nth_weekday(nth_week::rep n, weekday::rep dow, no_check_t) BOOST_NOEXCEPT
+      BOOST_CONSTEXPR nth_weekday(nth_week::rep n, weekday::rep dow, no_check_t) BOOST_NOEXCEPT
       :
-      n_(n),
-      dow_(dow)
+      n_(n, no_check),
+      dow_(dow, no_check)
       {
       }
 
       /**
        * @Return if the stored value is a valid one.
        */
-      bool is_valid() const BOOST_NOEXCEPT
+      BOOST_CONSTEXPR bool is_valid() const BOOST_NOEXCEPT
       {
         return (n_.is_valid() && dow_.is_valid());
       }
       /**
        * @Return The nth stored component.
        */
-      nth_week get_nth() const BOOST_NOEXCEPT
+      BOOST_CONSTEXPR nth_week get_nth() const BOOST_NOEXCEPT
       {
         return n_;
       }
       /**
        * @Return The weekday stored component.
        */
-      weekday get_weekday() const BOOST_NOEXCEPT
+      BOOST_CONSTEXPR weekday get_weekday() const BOOST_NOEXCEPT
       {
         return dow_;
       }
@@ -87,40 +86,43 @@
      * @param wd the weekday
      * @return a nth_weekday with the given parameters
      */
-    inline nth_weekday operator*(nth_week nw, weekday wd) BOOST_NOEXCEPT
+    inline BOOST_CONSTEXPR nth_weekday operator*(nth_week nw, weekday wd) BOOST_NOEXCEPT
     {
       return nth_weekday(nw, wd);
     }
 
-    inline nth_weekday operator*(last_t, weekday wd) BOOST_NOEXCEPT
+    inline BOOST_CONSTEXPR nth_weekday operator*(last_t, weekday wd) BOOST_NOEXCEPT
     {
       return nth_weekday(nth_week(6,no_check), wd);
     }
-    inline nth_weekday operator*(_1st_t, weekday wd) BOOST_NOEXCEPT
+    inline BOOST_CONSTEXPR nth_weekday operator*(_1st_t, weekday wd) BOOST_NOEXCEPT
     {
       return nth_weekday(nth_week(1,no_check), wd);
     }
-    inline nth_weekday operator*(_2nd_t, weekday wd) BOOST_NOEXCEPT
+    inline BOOST_CONSTEXPR nth_weekday operator*(_2nd_t, weekday wd) BOOST_NOEXCEPT
     {
       return nth_weekday(nth_week(2,no_check), wd);
     }
-    inline nth_weekday operator*(_3rd_t, weekday wd) BOOST_NOEXCEPT
+    inline BOOST_CONSTEXPR nth_weekday operator*(_3rd_t, weekday wd) BOOST_NOEXCEPT
     {
       return nth_weekday(nth_week(3,no_check), wd);
     }
-    inline nth_weekday operator*(_4th_t, weekday wd) BOOST_NOEXCEPT
+    inline BOOST_CONSTEXPR nth_weekday operator*(_4th_t, weekday wd) BOOST_NOEXCEPT
     {
       return nth_weekday(nth_week(4,no_check), wd);
     }
-    inline nth_weekday operator*(_5th_t, weekday wd) BOOST_NOEXCEPT
+    inline BOOST_CONSTEXPR nth_weekday operator*(_5th_t, weekday wd) BOOST_NOEXCEPT
     {
       return nth_weekday(nth_week(5,no_check), wd);
     }
-    inline nth_weekday operator*(unsigned n, weekday wd) BOOST_NOEXCEPT
+    inline nth_weekday operator*(unsigned n, weekday wd)
     {
       return nth_weekday(nth_week(n), wd);
     }
 
+    /**
+     * nth_weekday pseudo-literals.
+     */
     extern const nth_weekday last_sun;
     extern const nth_weekday last_mon;
     extern const nth_weekday last_tue;
Modified: sandbox/chrono_date/boost/chrono/date/tuples.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/tuples.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/tuples.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -6,8 +6,8 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#ifndef BOOST_CHRONO_DATE_DATE_TUPLES_HPP
-#define BOOST_CHRONO_DATE_DATE_TUPLES_HPP
+#ifndef BOOST_CHRONO_DATE_TUPLES_HPP
+#define BOOST_CHRONO_DATE_TUPLES_HPP
 
 #include <boost/chrono/config.hpp>
 #include <boost/chrono/date/no_check.hpp>
@@ -179,6 +179,9 @@
     }
 
 
+    /**
+     * month_day pseudo-literals.
+     */
     extern const month_day
         jan_01, jan_02, jan_03, jan_04, jan_05, jan_06, jan_07,
         jan_08, jan_09, jan_10, jan_11, jan_12, jan_13, jan_14,
Modified: sandbox/chrono_date/boost/chrono/date/week.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/week.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/week.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -6,15 +6,12 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#ifndef BOOST_CHRONO_DATE_DATE_WEEK_HPP
-#define BOOST_CHRONO_DATE_DATE_WEEK_HPP
+#ifndef BOOST_CHRONO_DATE_WEEK_HPP
+#define BOOST_CHRONO_DATE_WEEK_HPP
 
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/no_check.hpp>
-#include <boost/chrono/date/exceptions.hpp>
-#include <boost/chrono/date/detail/to_string.hpp>
+#include <boost/chrono/date/detail/bounded.hpp>
 
 namespace boost
 {
@@ -22,70 +19,17 @@
   {
 
     /**
-     * The class week is used to specify the week of the year.
+     * day tag
      */
-    class week
-    {
-    public:
-      typedef int_least8_t rep;
-      static const rep last_=53;
-      static const rep first_=1;
-      static const std::size_t size=last_-first_+1; // :6 bits
-
-      /**
-       * @Effects Constructs an object of class week by storing v.
-       * @Postconditions static_cast<rep>(*this) == v
-       * @Throws if v is outside of the range [1, 53], throws an exception of type bad_date.
-       */
-      explicit week(rep v)
-      : value_(v)
-      {
-        if (!is_valid())
-        {
-          throw bad_date("week day " + boost::chrono::to_string(int(v)) + " is out of range");
-        }
-      }
-      /**
-       * @Effects Constructs an object of class week by storing v.
-       * @Postconditions static_cast<rep>(*this) == v
-       */
-      BOOST_CONSTEXPR week(rep v,no_check_t) BOOST_NOEXCEPT
-      : value_(v)
-      {}
-
-      /**
-       * @return true if the v stored value is in the range [1, 53],
-       */
-      bool is_valid() const BOOST_NOEXCEPT
-      {
-        return (first_ <= value_ && value_ <= last_);
-      }
-      /**
-       * @Returns: the value of the stored int.
-       */
-      operator rep() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * @Returns: the value of the stored int.
-       */
-      rep value() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      static BOOST_CONSTEXPR week min BOOST_PREVENT_MACRO_SUBSTITUTION () BOOST_NOEXCEPT
-      {
-          return week(first_,no_check);
-      }
-      static BOOST_CONSTEXPR week max BOOST_PREVENT_MACRO_SUBSTITUTION () BOOST_NOEXCEPT
-      {
-          return week(last_,no_check);
-      }
-    private:
-      rep value_;
-    };
+    struct week_tag {};
+    /**
+     * The class week is used to specify the week of the year. Its range is [1,53].
+     */
+    typedef bounded<week_tag, 1, 53, int_least8_t> week;
 
+    /**
+     * week pseudo-literals.
+     */
     extern const week
          w_01, w_02, w_03, w_04, w_05, w_06, w_07, w_08, w_09,
          w_10, w_11, w_12, w_13, w_14, w_15, w_16, w_17, w_18, w_19,
Modified: sandbox/chrono_date/boost/chrono/date/weekday.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/weekday.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/weekday.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -6,15 +6,12 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#ifndef BOOST_CHRONO_DATE_DATE_WEEKDAY_HPP
-#define BOOST_CHRONO_DATE_DATE_WEEKDAY_HPP
+#ifndef BOOST_CHRONO_DATE_WEEKDAY_HPP
+#define BOOST_CHRONO_DATE_WEEKDAY_HPP
 
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/no_check.hpp>
-#include <boost/chrono/date/exceptions.hpp>
-#include <boost/chrono/date/detail/to_string.hpp>
+#include <boost/chrono/date/detail/bounded.hpp>
 
 namespace boost
 {
@@ -22,100 +19,43 @@
   {
 
     /**
+     * weekday tag
+     */
+    struct weekday_tag {};
+    /**
      * The class weekday is used to specify a day of the week.
      */
-    class weekday
+    class weekday: public bounded<weekday_tag, 0, 6, int_least8_t>
     {
-    public:
-      typedef int_least8_t rep;
+      typedef bounded<weekday_tag, 0, 6, int_least8_t> base_type;
 
-      static const rep last_=6;
-      static const rep first_=0;
-      static const int_least8_t size=last_-first_+1; //:3 bits
-      static const rep not_applicable=7;
+    public:
+      BOOST_STATIC_CONSTEXPR rep not_applicable=7;
 
       /**
        * @Effects Constructs an object of class weekday by storing v.
-       * @Postconditions static_cast<rep>(*this) == v
+       * @Postconditions static_cast<irep>(*this) == v
        * @Throws if v is outside of the range [0, 6], throws an exception of type bad_date.
        */
-      explicit weekday(rep v)
-      : value_(v)
-      {
-        if (!is_valid())
-        {
-          throw bad_date("week day " + boost::chrono::to_string(int(v)) + " is out of range");
-        }
-      }
+      BOOST_CONSTEXPR weekday(irep s) : base_type(s)
+      {}
       /**
        * @Effects Constructs an object of class weekday by storing v.
-       * @Postconditions static_cast<rep>(*this) == v
+       * @Postconditions static_cast<irep>(*this) == v
        */
-      BOOST_CONSTEXPR explicit weekday(rep wd, no_check_t) BOOST_NOEXCEPT
-      : value_(wd)
-      {
-      };
+      BOOST_CONSTEXPR weekday(irep s, no_check_t) BOOST_NOEXCEPT
+          : base_type(s, no_check)
+      {}
 
-      /**
-       * @Returns: the value of the stored int.
-       */
-      operator rep() const BOOST_NOEXCEPT
+      BOOST_CONSTEXPR bool is_not_applicable() const BOOST_NOEXCEPT
       {
-        return value_;
+        return value()==not_applicable;
       }
-      /**
-       * @Returns: the value of the stored int.
-       */
-      rep value() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-
-      /**
-       * @Return if the stored value is a valid one.
-       */
-      bool is_valid() const BOOST_NOEXCEPT
-      {
-        return (first_ <= value_ && value_ <= last_);
-      }
-
-
-      weekday next() const BOOST_NOEXCEPT
-      {
-        return weekday(((value_+1)%size),no_check);
-      }
-      weekday prev() BOOST_NOEXCEPT
-      {
-        return weekday((value_+size-1)%size,no_check);
-      }
-
-      /**
-       * @Returns: the first day of the week.
-       */
-      static BOOST_CONSTEXPR weekday first() BOOST_NOEXCEPT
-      {
-          return weekday(first_,no_check);
-      }
-      /**
-       * @Returns: the last day of the week.
-       */
-      static BOOST_CONSTEXPR weekday last() BOOST_NOEXCEPT
-      {
-          return weekday(last_,no_check);
-      }
-      static BOOST_CONSTEXPR weekday min BOOST_PREVENT_MACRO_SUBSTITUTION () BOOST_NOEXCEPT
-      {
-          return weekday(first_,no_check);
-      }
-      static BOOST_CONSTEXPR weekday max BOOST_PREVENT_MACRO_SUBSTITUTION () BOOST_NOEXCEPT
-      {
-          return weekday(last_,no_check);
-      }
-    private:
-      rep value_;
     };
 
     /**
+     * weekday pseudo-literals.
+     *
      * These const weekday objects are constructed prior to first use with the following values:
      *
      * const weekday sun(0);
@@ -127,6 +67,17 @@
      * const weekday sat(6);
      *
      */
+#ifndef  BOOST_NO_CXX11_CONSTEXPR
+    BOOST_CONSTEXPR_OR_CONST weekday
+      sun(0, no_check)
+    , mon(1, no_check)
+    , tue(2, no_check)
+    , wed(3, no_check)
+    , thu(4, no_check)
+    , fri(5, no_check)
+    , sat(6, no_check)
+    ;
+#else
     extern const weekday sun;
     extern const weekday mon;
     extern const weekday tue;
@@ -134,7 +85,12 @@
     extern const weekday thu;
     extern const weekday fri;
     extern const weekday sat;
-
+#endif
+    /**
+     * Overload for string vonversion.
+     * @param v the weekday
+     * @return the string representation.
+     */
     inline std::string to_string(weekday v) {
       switch (v) {
       case 0: return "Sun";
@@ -144,7 +100,7 @@
       case 4: return "Thu";
       case 5: return "Fri";
       case 6: return "Sat";
-      default: throw bad_date("week day " + boost::chrono::to_string(unsigned(v.value())) + " is out of range");
+      default: throw_exception( bad_date("week day " + boost::chrono::to_string(unsigned(v.value())) + " is out of range") );
 
       }
     }
Modified: sandbox/chrono_date/boost/chrono/date/year.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/year.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/year.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -6,97 +6,51 @@
 //  Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
 //  http://www.boost.org/LICENSE_1_0.txt).
 
-#ifndef BOOST_CHRONO_DATE_DATE_YEAR_HPP
-#define BOOST_CHRONO_DATE_DATE_YEAR_HPP
+#ifndef BOOST_CHRONO_DATE_YEAR_HPP
+#define BOOST_CHRONO_DATE_YEAR_HPP
 
 #include <boost/cstdint.hpp>
-#include <boost/chrono/config.hpp>
-#include <boost/chrono/date/no_check.hpp>
+#include <boost/chrono/date/detail/bounded.hpp>
 #include <boost/chrono/date/month.hpp>
-#include <boost/chrono/date/exceptions.hpp>
 #include <boost/chrono/date/date_durations.hpp>
-#include <boost/chrono/date/detail/to_string.hpp>
 #include <boost/chrono/date/detail/helpers.hpp>
 
 namespace boost
 {
   namespace chrono
   {
+    /**
+     * year tag
+     */
+    struct year_tag {};
 
     /**
      * The class year is used to specify the year when constructing a date.
      * It also defines the range of the date class by restricting the value of
      * the year to a range.
      *
-     * That range shall be at least [year(-32767)/jan/1 thru year(32767)/dec/31].
+     * That range shall be at least [year(-32767)/jan/1 thru year(32767)/dec/31]. Its range is [-32768, 32767].
      */
-    class year
+    class year : public bounded<year_tag, -32768, 32767, int_least32_t>
     {
+      typedef bounded<year_tag, -32768, 32767, int_least32_t> base_type;
     public:
       /**
-       * Internal representation of a year.
-       *
-       * In order for year to detect overflow, the integral type used to construct the year must have a range greater than that of year.
-       */
-      typedef int_least32_t rep;
-      static const rep last_ = 32767;
-      static const rep first_ = -32768;
-      static const std::size_t size = last_ - first_ + 1; // :16 bits
-
-      /**
        * @Effects: Constructs an object of class year by storing y.
        * @Postconditions: static_cast<int>(*this) == y.
        * @Throws: if y is outside of the supported range, throws an exception of type bad_date.
        */
-      explicit year(rep v) :
-        value_(v)
-      {
-        if (!is_valid())
-        {
-          throw bad_date("year " + to_string(v) + " is out of range");
-        }
-      }
+      BOOST_CONSTEXPR explicit year(irep v)
+      : base_type(v)
+      {}
 
       /**
        * @Effects: Constructs an object of class year by storing y.
        * @Postconditions: static_cast<int>(*this) == y.
        */
-      BOOST_CONSTEXPR year(rep y, no_check_t) BOOST_NOEXCEPT
-      :value_(y)
-      {}
-      /**
-       * @Return if the stored value is a valid one.
-       */
-      bool is_valid() const BOOST_NOEXCEPT
-      {
-        return (first_ <= value_ && value_ <= last_);
-      }
-
-      /**
-       * Returns: the value of the stored int.
-       */
-      operator rep() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-      /**
-       * Returns: the value of the stored int.
-       */
-      rep value() const BOOST_NOEXCEPT
-      {
-        return value_;
-      }
-
-      //      year& operator++() BOOST_NOEXCEPT
-      //      {
-      //        ++value_;
-      //        return *this;
-      //      }
-      //      year& operator--() BOOST_NOEXCEPT
-      //      {
-      //        --value_;
-      //        return *this;
-      //      }
+      BOOST_CONSTEXPR year(irep y, no_check_t) BOOST_NOEXCEPT
+      : base_type(y, no_check)
+        {}
 
       /**
        * @Return the number of days of this year.
@@ -116,7 +70,7 @@
        */
       inline days days_since_epoch() const BOOST_NOEXCEPT
       {
-        return days(days_before_year(value_));
+        return days(days_before_year(value()));
       }
 
       /**
@@ -124,26 +78,14 @@
        */
       bool is_leap() const BOOST_NOEXCEPT
       {
-        int32_t y = value_;
+        int32_t y = value();
         return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
       }
 
-      static BOOST_CONSTEXPR year zero()
+      static BOOST_CONSTEXPR year zero() BOOST_NOEXCEPT
       {
         return year(0, no_check);
       }
-      static BOOST_CONSTEXPR year min BOOST_PREVENT_MACRO_SUBSTITUTION ()
-      {
-        return year(first_, no_check);
-      }
-      static BOOST_CONSTEXPR year max BOOST_PREVENT_MACRO_SUBSTITUTION ()
-      {
-        return year(last_, no_check);
-      }
-
-    private:
-      rep value_;
-
     };
 
   } // chrono
Modified: sandbox/chrono_date/boost/chrono/date/ymd_date.hpp
==============================================================================
--- sandbox/chrono_date/boost/chrono/date/ymd_date.hpp	(original)
+++ sandbox/chrono_date/boost/chrono/date/ymd_date.hpp	2013-05-03 16:03:24 EDT (Fri, 03 May 2013)
@@ -74,7 +74,7 @@
        * Else constructs a @c ymd_date for which <c>get_year() == y && get_month() == m && get_day() == d</c>.
        * @Throws @c bad_date if the specified @c ymd_date is invalid.
        */
-      ymd_date(chrono::year y, chrono::month m, chrono::day d);
+      ymd_date(year y, month m, day d);
       /**
        * @Effect Constructs a @c ymd_date constructor from @c year, @c month, @c day stored in the arguments as follows:
        * Constructs a ymd_date so that <c>get_year() == y && get_month() = m && get_day() == d</c>.
@@ -89,13 +89,13 @@
        * @Throws bad_date if the specified ymd_date is invalid.
        * @Note This constructor can be more efficient as the month_day is already valid.
        */
-      ymd_date(chrono::year y, chrono::month_day md);
+      ymd_date(year y, month_day md);
       /**
        * @Effect Constructs a ymd_date using the year, month_day stored in the arguments as follows:
        * Constructs a ymd_date for which get_year() == y, get_month() == md.get_month(), get_day() == md.get_month().
        * @Note This constructor can be more efficient as the month_day is already valid.
        */
-      ymd_date(chrono::year::rep, chrono::month_day, no_check_t) BOOST_NOEXCEPT;
+      ymd_date(year::rep, month_day, no_check_t) BOOST_NOEXCEPT;
 
       /**
        * @Effect Constructs a ymd_date using the year, day_of_year stored in the arguments as follows:
@@ -105,7 +105,7 @@
        * @Throws bad_date if the specified ymd_date is invalid.
        * @Note This constructor can be more efficient as the check is simple.
        */
-      ymd_date(chrono::year y, chrono::day_of_year doy);
+      ymd_date(year y, day_of_year doy);
       /**
        * @Effect Constructs a ymd_date using the year, day_of_year stored in the arguments as follows:
        * Constructs a ymd_date for which days_since_epoch() == y.days_since_epoch()+doy.value()
@@ -117,7 +117,7 @@
        * @Effect Constructs a ymd_date using the days given as parameter so that:
        * days_since_epoch() == ds.count()
        */
-      explicit ymd_date(chrono::days);
+      explicit ymd_date(days);
       /**
        * Unchecked constructor from days.
        */
@@ -209,17 +209,17 @@
        * an exception of type bad_date.
        *
        */
-      explicit ymd_date(boost::chrono::system_clock::time_point tp);
+      explicit ymd_date(system_clock::time_point tp);
       /**
-       * @Returns: A chrono::system_clock::time_point which represents the ymd_date
+       * @Returns: A system_clock::time_point which represents the ymd_date
        * referred to by *this at 00:00:00 UTC.
        *
        * @Throws: If the conversion to tp overflows the range of
-       * boost::chrono::system_clock::time_point, throws an exception of type bad_date.
+       * system_clock::time_point, throws an exception of type bad_date.
        *
        */
       // explicit
-      operator boost::chrono::system_clock::time_point () const;
+      operator system_clock::time_point () const;
 
       bool is_valid() const BOOST_NOEXCEPT;
 
@@ -245,25 +245,25 @@
       }
 
       /**
-       * Returns: chrono::day(d_,no_check).
+       * Returns: day(d_,no_check).
        */
-      chrono::day get_day() const BOOST_NOEXCEPT
+      day get_day() const BOOST_NOEXCEPT
       {
-        return chrono::day(d_,no_check);
+        return day(d_,no_check);
       }
       /**
-       * Returns: chrono::month(m_,no_check).
+       * Returns: month(m_,no_check).
        */
-      chrono::month get_month() const BOOST_NOEXCEPT
+      month get_month() const BOOST_NOEXCEPT
       {
-        return chrono::month(m_,no_check);
+        return month(m_,no_check);
       }
       /**
-       * Returns: chrono::year(y_,no_check).
+       * Returns: year(y_,no_check).
        */
-      chrono::year get_year() const BOOST_NOEXCEPT
+      year get_year() const BOOST_NOEXCEPT
       {
-        return chrono::year(y_,no_check);
+        return year(y_,no_check);
       }
       month_day get_month_day() const BOOST_NOEXCEPT
       {
@@ -290,14 +290,14 @@
        * @Returns: A weekday constructed with an int corresponding to *this
        * ymd_date's day of the week (a value in the range of [0 - 6], 0 is Sunday).
        */
-      chrono::weekday get_weekday() const BOOST_NOEXCEPT
+      weekday get_weekday() const BOOST_NOEXCEPT
       {
-        return chrono::weekday((x_ + 1) % weekday::size, no_check);
+        return weekday((x_ + 1) % weekday::size, no_check);
       }
 #elif BOOST_CHRONO_DATE_YMD_DATE_DESIGN == 3
-      chrono::weekday get_weekday() const BOOST_NOEXCEPT
+      weekday get_weekday() const BOOST_NOEXCEPT
       {
-        return chrono::weekday((day_number_from_ymd()+1) % weekday::size,no_check);
+        return weekday((day_number_from_ymd()+1) % weekday::size,no_check);
       }
 #endif