diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2024-03-06 10:24:11 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2024-03-06 10:24:11 +0100 |
commit | 4538829ab86b5a1cd4e845e7eab165029c9d6d46 (patch) | |
tree | bbadf39aed0610c8f8f7b41fefff47773b8ac205 /libcutl/cutl/container/any.hxx | |
parent | 23d41842168ac1a1580111b9c5c73500ceee3d57 (diff) | |
parent | aad5ad9bf0c02aa4e79bc6b7d6c934612fff4026 (diff) |
Update upstream source from tag 'upstream/4.2.0'
Update to upstream version '4.2.0'
with Debian dir 1b38df7bbcf313223de3c50107ac0255090fe647
Diffstat (limited to 'libcutl/cutl/container/any.hxx')
-rw-r--r-- | libcutl/cutl/container/any.hxx | 152 |
1 files changed, 0 insertions, 152 deletions
diff --git a/libcutl/cutl/container/any.hxx b/libcutl/cutl/container/any.hxx deleted file mode 100644 index 5dd1c25..0000000 --- a/libcutl/cutl/container/any.hxx +++ /dev/null @@ -1,152 +0,0 @@ -// file : cutl/container/any.hxx -// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC -// license : MIT; see accompanying LICENSE file - -#ifndef CUTL_CONTAINER_ANY_HXX -#define CUTL_CONTAINER_ANY_HXX - -#include <memory> // std::auto_ptr -#include <typeinfo> // std::type_info - -#include <cutl/exception.hxx> - -#include <cutl/details/export.hxx> - -namespace cutl -{ - namespace container - { - class LIBCUTL_EXPORT any - { - public: - struct LIBCUTL_EXPORT typing: exception {}; - - public: - any () - { - } - - template <typename X> - any (X const& x) - : holder_ (new holder_impl<X> (x)) - { - } - - any (any const& x) - : holder_ (x.holder_->clone ()) - { - } - - template <typename X> - any& - operator= (X const& x) - { - holder_.reset (new holder_impl<X> (x)); - return *this; - } - - any& - operator= (any const& x) - { - holder_.reset (x.holder_->clone ()); - return *this; - } - - public: - template <typename X> - X& - value () - { - if (holder_impl<X>* p = dynamic_cast<holder_impl<X>*> (holder_.get ())) - return p->value (); - else - throw typing (); - } - - template <typename X> - X const& - value () const - { - if (holder_impl<X>* p = dynamic_cast<holder_impl<X>*> (holder_.get ())) - return p->value (); - else - throw typing (); - } - - std::type_info const& - type_info () const - { - return holder_->type_info (); - } - - public: - bool - empty () const - { - return holder_.get () == 0; - } - - void - reset () - { - return holder_.reset (); - } - - private: - class LIBCUTL_EXPORT holder - { - public: - virtual - ~holder () {} - - virtual holder* - clone () const = 0; - - virtual std::type_info const& - type_info () const = 0; - }; - - template <typename X> - class holder_impl: public holder - { - public: - holder_impl (X const& x) - : x_ (x) - { - } - - virtual holder_impl* - clone () const - { - return new holder_impl (x_); - } - - virtual std::type_info const& - type_info () const - { - return typeid (x_); - } - - X const& - value () const - { - return x_; - } - - X& - value () - { - return x_; - } - - private: - X x_; - }; - - private: - std::auto_ptr<holder> holder_; - }; - } -} - -#endif // CUTL_CONTAINER_ANY_HXX |