types/tagged: add const accessor

This commit is contained in:
Danny Robson 2019-03-11 12:11:03 +11:00
parent 8c42829f4f
commit d124fffcb3

View File

@ -92,11 +92,20 @@ namespace cruft {
InnerT& InnerT&
get (void)& get (void)&
{ {
CHECK_EQ (InnerT::tag, m_tag); CHECK (InnerT::tag == m_tag);
return *cruft::cast::alignment<InnerT*> (m_data + 0); return *cruft::cast::alignment<InnerT*> (m_data + 0);
} }
template <typename InnerT>
InnerT const&
get (void) const&
{
CHECK (InnerT::tag == m_tag);
return *cruft::cast::alignment<InnerT const*> (m_data + 0);
}
/// Set the inner member to a supplied value and store the associated /// Set the inner member to a supplied value and store the associated
/// type code. /// type code.
template <typename InnerT> template <typename InnerT>