summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/wax.hpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/host/include/uhd/wax.hpp b/host/include/uhd/wax.hpp
index 1d5054351..4fd54ba14 100644
--- a/host/include/uhd/wax.hpp
+++ b/host/include/uhd/wax.hpp
@@ -124,6 +124,17 @@ namespace wax{
*/
const std::type_info & type(void) const;
+ /*!
+ * Cast this obj into the desired type.
+ * Usage myobj.as<type>()
+ *
+ * \return an object of the desired type
+ * \throw wax::bad_cast when the cast fails
+ */
+ template<class T> T as(void) const{
+ return boost::any_cast<T>(resolve());
+ }
+
private:
//private interface (override in subclasses)
virtual void get(const obj &, obj &);
@@ -137,7 +148,6 @@ namespace wax{
* \return a boost any type with contents
*/
boost::any resolve(void) const;
- template<class T> friend T cast(const obj &);
//private contents of this obj
boost::any _contents;
@@ -159,7 +169,7 @@ namespace wax{
* \throw wax::bad_cast when the cast fails
*/
template<class T> T cast(const obj &val){
- return boost::any_cast<T>(val.resolve());
+ return val.as<T>();
}
} //namespace wax