X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftrunk%2FETL%2F_trivial.h;h=a819c1d402ab62b1ad3e1ddcbf0ff1b6d8c47b43;hb=e0dedc46e8ab6b258be81887689b0c0fd60def0c;hp=4732ad3212ddc0823988e6be74a8ff88fa82aaf8;hpb=b3016b249333ac0ab0008d8c6c4d9029b2ff30c9;p=synfig.git diff --git a/ETL/trunk/ETL/_trivial.h b/ETL/trunk/ETL/_trivial.h index 4732ad3..a819c1d 100644 --- a/ETL/trunk/ETL/_trivial.h +++ b/ETL/trunk/ETL/_trivial.h @@ -1,7 +1,7 @@ /*! ======================================================================== ** Extended Template Library ** Trivializing Template Class Implementation -** $Id: _trivial.h,v 1.1.1.1 2005/01/04 01:31:48 darco Exp $ +** $Id$ ** ** Copyright (c) 2002 Robert B. Quattlebaum Jr. ** @@ -24,8 +24,8 @@ /* === S T A R T =========================================================== */ -#ifndef __ETL_TRIVIAL_H -#define __ETL_TRIVIAL_H +#ifndef __ETL__TRIVIAL_H +#define __ETL__TRIVIAL_H /* === H E A D E R S ======================================================= */ @@ -55,33 +55,33 @@ class trivial typedef const T& const_reference; typedef T* pointer; typedef const T* const_pointer; - + char data[sizeof(T)]; public: - operator reference() + operator reference() { return *reinterpret_cast(data); } // HACK - Rather dangerous - //operator reference()const + //operator reference()const //{ return *reinterpret_cast(const_cast(data)); } - - operator const_reference()const + + operator const_reference()const { return *reinterpret_cast(data); } - + reference get() { return *reinterpret_cast(data); } const_reference get()const { return *reinterpret_cast(data); } - + void construct() { new(&get()) value_type(); } void destruct() { get().~value_type(); } - + void destroy() { destruct(); } - + template reference operator=(const U &rhs) { return get()=rhs; } @@ -125,11 +125,11 @@ public: template reference operator<<=(const U &rhs) { return get()<<=rhs; } - - operator bool()const + + operator bool()const { return get(); } - bool operator!()const + bool operator!()const { return !get(); } }; // END of template class trivial