summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/utils/any.hh
diff options
context:
space:
mode:
authorschodet2005-03-13 20:15:19 +0000
committerschodet2005-03-13 20:15:19 +0000
commit681ed261c49d38f35f70e6c49dc19b1c5c1fc48d (patch)
tree2920254843815d7410b9d01c9519a6a72ae3e73a /2005/i/robert/src/utils/any.hh
parentd77b1324361f5d598d52baaac09e93236d020198 (diff)
Ajout de commentaires.
changeemnt de any_cast pour retourner un const &.
Diffstat (limited to '2005/i/robert/src/utils/any.hh')
-rw-r--r--2005/i/robert/src/utils/any.hh15
1 files changed, 13 insertions, 2 deletions
diff --git a/2005/i/robert/src/utils/any.hh b/2005/i/robert/src/utils/any.hh
index 1c36875..8a24a06 100644
--- a/2005/i/robert/src/utils/any.hh
+++ b/2005/i/robert/src/utils/any.hh
@@ -28,7 +28,7 @@
#include <exception>
#include <iostream>
-/// Class containing anything.
+/// This class can contain a data of any type.
class any
{
class AbstractHolder;
@@ -43,11 +43,16 @@ class any
any (const any &other);
/// Destructor.
~any (void);
+ /// Swap content between two any objects.
any &swap (any &other);
+ /// Copy another any object.
any &operator= (const any &other);
+ /// Copy another object into this any.
template<typename T>
any &operator= (const T &value);
+ /// Test if the any object is empty.
bool empty (void) const;
+ /// Return the std::type_info of the contained object.
const std::type_info &type (void) const;
private:
template<typename T>
@@ -77,6 +82,7 @@ class any
};
};
+/// Object throw if a any_cast returning a reference fail.
class bad_any_cast : public std::bad_cast
{
public:
@@ -86,18 +92,23 @@ class bad_any_cast : public std::bad_cast
}
};
+/// Return a pointer to the contained object or 0 on faillure.
template<typename T>
T *
any_cast (any *rhs);
+/// Return a const pointer to the contained object or 0 on faillure.
template<typename T>
const T *
any_cast (const any *rhs);
+/// Return a const reference to the contained object or throw a bad_any_cast
+/// on faillure.
template<typename T>
-T
+const T &
any_cast (const any &rhs);
+/// Print the contained object.
std::ostream &
operator<< (std::ostream &os, const any &rhs);