diff options
| author | ljfa-ag <ljfa-ag@web.de> | 2015-07-18 21:57:58 +0200 |
|---|---|---|
| committer | ljfa-ag <ljfa-ag@web.de> | 2015-07-18 21:57:58 +0200 |
| commit | 61d29e8ac2efc53ca502645a9199f9377832404d (patch) | |
| tree | 552f66e6685b4d2e7ea58ea1553335f5f8b4f816 | |
| parent | c28d3777bf5ee435e313e700bde2c0c84562b369 (diff) | |
| download | Project-Tick-61d29e8ac2efc53ca502645a9199f9377832404d.tar.gz Project-Tick-61d29e8ac2efc53ca502645a9199f9377832404d.zip | |
Add static_assert to ensure correct types for as
| -rw-r--r-- | include/value.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/value.h b/include/value.h index c82aeb9097..2dc4e10207 100644 --- a/include/value.h +++ b/include/value.h @@ -22,6 +22,7 @@ #include "tag.h" #include <string> +#include <type_traits> namespace nbt { @@ -179,12 +180,14 @@ private: template<class T> T& value::as() { + static_assert(std::is_base_of<tag, T>::value, "T must be a subclass of tag"); return dynamic_cast<T&>(get()); } template<class T> const T& value::as() const { + static_assert(std::is_base_of<tag, T>::value, "T must be a subclass of tag"); return dynamic_cast<T&>(get()); } |
