bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Boxed types for CommonC++


From: David Sugar
Subject: Re: Boxed types for CommonC++
Date: Tue, 13 Jan 2004 07:36:17 -0500
User-agent: KMail/1.5.3

I really had not had time to go over this as yet, since I am getting ready to 
leave for Aachen.  But I will discuss this with Federico on Thursday.  We do 
need to lay out a roadmap for post 1.1 and this probably fits into that.

On Sunday 11 January 2004 12:28 am, Marc Boris Dürner wrote:
> Hi,
> Here is a proposed boxed type system for CommonC++. Comments?
>
> regards,
> Marc
>
> ----------------------------------------------------------------------
>
> #include <stdint.h>
>
> template <typename T>
> class BoxedType {
>    public:
>    BoxedType() : value(0) {}
>    BoxedType(const T& x) : value(0) {value = x;}
>    ~BoxedType() {}
>    const T& operator*() const {return value;}
>    void operator=(const T& x) {value = x;}
>    BoxedType<T>& operator +=(const BoxedType<T>& x) {value += *x; return
> *this;}
>    bool operator==(const BoxedType<T>& x) const {return value == *x;}
>    bool operator!=(const BoxedType<T>& x) const {return value != *x;}
>    bool operator<(const BoxedType<T>& x) const {return value < *x;}
>    bool operator>(const BoxedType<T>& x) const {return value > *x;}
>    bool operator<=(const BoxedType<T>& x) const {return value <= *x;}
>    bool operator>=(const BoxedType<T>& x) const {return value >= *x;}
>    BoxedType<T> operator&(const BoxedType<T>& x) const {return value & *x;}
>    BoxedType<T>& operator++() { ++value; return *this; }
>    BoxedType<T> operator++(int) {BoxedType<T> x = *this; ++*this; return x;
> }
>    BoxedType<T>& operator--() { --value; return *this; }
>    BoxedType<T> operator--(int) {BoxedType<T> x = *this; --*this; return x;
> }
>    BoxedType<T> operator<<(const int& i) {return value<<i;}
>    BoxedType<T> operator>>(const int& i) {return value>>i;}
>    protected:
>    T value;
> };
>
>  // integer
> typedef BoxedType<int> Int;
> typedef BoxedType<long int> LongInt;
> typedef BoxedType<long long int> LongLongInt;
> typedef BoxedType<int8_t> Int8;
> typedef BoxedType<int16_t> Int16;
> typedef BoxedType<int32_t> Int32;
> typedef BoxedType<int64_t> Int64;
> typedef BoxedType<unsigned int> UInt;
> typedef BoxedType<unsigned long int> ULongInt;
> typedef BoxedType<unsigned long long int> ULongLongInt;
> typedef BoxedType<uint8_t> UInt8;
> typedef BoxedType<uint16_t> UInt16;
> typedef BoxedType<uint32_t> UInt32;
> typedef BoxedType<uint64_t> UInt64;
>
> //float
> typedef BoxedType<float> Float;
>
> // char
> typedef BoxedType<char> Char;
> typedef BoxedType<unsigned char> UChar;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]