X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=ETL%2Ftags%2F0.04.12%2FETL%2F_trivial.h;fp=ETL%2Ftags%2F0.04.12%2FETL%2F_trivial.h;h=0000000000000000000000000000000000000000;hb=3a6643238c67c043fc3592837a05d6d2861967f1;hp=049b26827f822b955ef7cd68ebb5917281783ae6;hpb=47fce282611fbba1044921d22ca887f9b53ad91a;p=synfig.git diff --git a/ETL/tags/0.04.12/ETL/_trivial.h b/ETL/tags/0.04.12/ETL/_trivial.h deleted file mode 100644 index 049b268..0000000 --- a/ETL/tags/0.04.12/ETL/_trivial.h +++ /dev/null @@ -1,164 +0,0 @@ -/*! ======================================================================== -** Extended Template Library -** Trivializing Template Class Implementation -** $Id$ -** -** Copyright (c) 2002 Robert B. Quattlebaum Jr. -** -** This package is free software; you can redistribute it and/or -** modify it under the terms of the GNU General Public License as -** published by the Free Software Foundation; either version 2 of -** the License, or (at your option) any later version. -** -** This package is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -** General Public License for more details. -** -** === N O T E S =========================================================== -** -** This is an internal header file, included by other ETL headers. -** You should not attempt to use it directly. -** -** ========================================================================= */ - -/* === S T A R T =========================================================== */ - -#ifndef __ETL_TRIVIAL_H -#define __ETL_TRIVIAL_H - -/* === H E A D E R S ======================================================= */ - -/* === M A C R O S ========================================================= */ - -/* === T Y P E D E F S ===================================================== */ - -/* === C L A S S E S & S T R U C T S ======================================= */ - -_ETL_BEGIN_NAMESPACE - -/*! ======================================================================== -** \class Trivial -** \brief Trivializes the constructor of a given class -** -** This class makes the given type 'trivial', -** effectively disabling the constructor and -** destructor. (This is useful for unions) -** Some extra casting may be necessary to get -** it to work properly. -*/ -template -class trivial -{ - typedef T value_type; - typedef T& reference; - typedef const T& const_reference; - typedef T* pointer; - typedef const T* const_pointer; - - char data[sizeof(T)]; -public: - operator reference() - { return *reinterpret_cast(data); } - - // HACK - Rather dangerous - //operator reference()const - //{ return *reinterpret_cast(const_cast(data)); } - - 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; } - - templatereference - operator=(const trivial &rhs) - { return get()=rhs.get(); } - - template reference - operator+=(const U &rhs) - { return get()+=rhs; } - - template reference - operator-=(const U &rhs) - { return get()-=rhs; } - - template reference - operator*=(const U &rhs) - { return get()*=rhs; } - - template reference - operator/=(const U &rhs) - { return get()/=rhs; } - - template reference - operator%=(const U &rhs) - { return get()%=rhs; } - - template reference - operator^=(const U &rhs) - { return get()^=rhs; } - - template reference - operator&=(const U &rhs) - { return get()&=rhs; } - - template reference - operator>>=(const U &rhs) - { return get()>>=rhs; } - - template reference - operator<<=(const U &rhs) - { return get()<<=rhs; } - - operator bool()const - { return get(); } - - bool operator!()const - { return !get(); } -}; // END of template class trivial - -_ETL_END_NAMESPACE - -//#include - -/* -template std::basic_istream<_CharT, _Traits>& -operator>>(std::basic_istream<_CharT, _Traits>& s, etl::trivial& rhs) -{ return s>>(T)(rhs); } - -template std::basic_ostream<_CharT, _Traits>& -operator<<(std::basic_ostream<_CharT, _Traits>& s, const etl::trivial& rhs) -{ return s<<(T)(rhs); } -*/ - -/* -template std::istream& -operator>>(std::istream& s, etl::trivial& rhs) -{ return s>>(T)(rhs); } - -template std::ostream& -operator<<(std::ostream& s, const etl::trivial& rhs) -{ return s<<(T)(rhs); } -*/ - -/* === E X T E R N S ======================================================= */ - -/* === E N D =============================================================== */ - -#endif