summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/utils/any.tcc
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.tcc
parentd77b1324361f5d598d52baaac09e93236d020198 (diff)
Ajout de commentaires.
changeemnt de any_cast pour retourner un const &.
Diffstat (limited to '2005/i/robert/src/utils/any.tcc')
-rw-r--r--2005/i/robert/src/utils/any.tcc12
1 files changed, 11 insertions, 1 deletions
diff --git a/2005/i/robert/src/utils/any.tcc b/2005/i/robert/src/utils/any.tcc
index c7fd4a0..57ee848 100644
--- a/2005/i/robert/src/utils/any.tcc
+++ b/2005/i/robert/src/utils/any.tcc
@@ -52,6 +52,7 @@ any::~any (void)
delete holder_;
}
+/// Swap content between two any objects.
inline
any &
any::swap (any &other)
@@ -60,6 +61,7 @@ any::swap (any &other)
return *this;
}
+/// Copy another any object.
inline
any &
any::operator= (const any &other)
@@ -68,6 +70,7 @@ any::operator= (const any &other)
return *this;
}
+/// Copy another object into this any.
template<typename T>
any &
any::operator= (const T &value)
@@ -76,6 +79,7 @@ any::operator= (const T &value)
return *this;
}
+/// Test if the any object is empty.
inline
bool
any::empty (void) const
@@ -83,6 +87,7 @@ any::empty (void) const
return !holder_;
}
+/// Return the std::type_info of the contained object.
inline
const std::type_info &
any::type (void) const
@@ -123,6 +128,7 @@ any::Holder<T>::print (std::ostream &os) const
return os << value_;
}
+/// Return a pointer to the contained object or 0 on faillure.
template<typename T>
T *
any_cast (any *rhs)
@@ -132,6 +138,7 @@ any_cast (any *rhs)
: 0;
}
+/// Return a const pointer to the contained object or 0 on faillure.
template<typename T>
const T *
any_cast (const any *rhs)
@@ -139,8 +146,10 @@ any_cast (const any *rhs)
return any_cast<T> (const_cast<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)
{
const T *value = any_cast<T> (&rhs);
@@ -149,6 +158,7 @@ any_cast (const any &rhs)
return *value;
}
+/// Print the contained object.
inline
std::ostream &
operator<< (std::ostream &os, const any &rhs)