types/tagged: add type query

This commit is contained in:
Danny Robson 2020-04-01 14:52:17 +11:00
parent 757253ee4e
commit c9b5605213

View File

@ -82,6 +82,15 @@ namespace cruft {
auto tag (void) { return m_tag; } auto tag (void) { return m_tag; }
/// Returns true if the contained type is the same as the type
/// specified in the template parameter.
template <typename QueryT>
bool is (void) const noexcept
{
return QueryT::tag == m_tag;
}
///-------------------------------------------------------------------- ///--------------------------------------------------------------------
/// Return a reference to a stored value of known type. /// Return a reference to a stored value of known type.
/// ///