Boost logo

Boost :

From: christopher diggins (cdiggins_at_[hidden])
Date: 2004-05-24 10:39:57


----- Original Message -----
From: "Daryle Walker" <darylew_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
Sent: Saturday, May 22, 2004 1:37 PM
Subject: Re: [boost] Ranged type mini-library submission

> On 5/16/04 11:09 AM, "christopher diggins" <cdiggins_at_[hidden]> wrote:
[snip]
>
> Should those "value" types be more like "value_type" to reduce confusion
on
> what that member is?
>
> --
> Daryle Walker
> Mac, Internet, and Video Game Junkie
> darylew AT hotmail DOT com

The version at http://www.cdiggins.com/constrained_value.hpp is less
confusing I think. Though I still use value instead of value_type, I think
it is perhaps more clear from the context that value is a type as opposed to
another kind of identifier. I have included the latest version below so that
a copy will exist for perpetuity in the list archives. I will be posting
documentation on Tuesday.

#ifndef BOOST_CV_HPP
#define BOOST_CV_HPP
#include <boost/mpl/if.hpp>
namespace boost
{
  namespace cv
  {
    template
    <
      class constraints_policy,
      bool implicit_conversion_policy = true
>
    class constrained_value {
      private:
        struct unused_struct { };
      public:
        typedef constrained_value<constraints_policy,
implicit_conversion_policy> self;
        typedef typename constraints_policy::value value;
        typedef typename mpl::if_c<implicit_conversion_policy, value,
unused_struct>::type value_parameter;
        static constraints_policy get_constraints() { return
constraints_policy(); }
        constrained_value() { }
        constrained_value(const self& x) { assign(x.get_value()); }
        constrained_value(value_parameter x) { assign(x); }
        const value get_value() const { return m; }
        operator value() { return m; }
        self& operator=(const self& x) { assign(x.get_value()); return
*this; }
        self& operator=(value_parameter x) { assign(x); return *this; }
        void assign(unused_struct x) { }
        void assign(value_parameter x) { constraints_policy::assign(x, m); }
      private:
        value m;
    };
  };
};
#endif // BOOST_CV_HPP

Christopher Diggins
http://www.cdiggins.com
http://www.heron-language.com


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk