Skip to content

Commit 4503718

Browse files
committed
added untag to simplify tag_cast'ing to no_tag
1 parent 166109f commit 4503718

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

quantity.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,10 @@ template<typename U, typename S, typename V, typename T>
729729
constexpr auto tag_cast(const quantity<U,S,V,T>& q) {return implicit_quantity_caster<U,S,V,T,false,false,true>{q};}
730730
template<typename NewTag, typename U, typename S, typename V, typename T>
731731
constexpr auto tag_cast(const quantity<U,S,V,T>& q) {return quantity<U,S,V,NewTag>{tag_cast(q)};}
732+
template<typename U, typename V>
733+
constexpr auto untag(const quantity<U,V>& q) {return tag_cast<typename quantity<U,V>::untag::tag_type>(q);}
734+
template<typename U, typename V>
735+
constexpr auto untag(const quantity<U,V>& q) {return tag_cast<typename quantity<U,V>::untag::tag_type>(q);}
732736
/** @} */
733737

734738

test/test_quantity.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ SUBCASE("quantity casts") {
584584
}
585585

586586
SUBCASE("testing tag_cast") {
587-
using namespace unlib;
588587
using test_qa = test_quantity::retag<tag_t<struct tag_a>>;
589588
using test_qb = test_quantity::retag<tag_t<struct tag_b>>;
590589

@@ -603,6 +602,12 @@ SUBCASE("quantity casts") {
603602
CHECK(qa.get() == doctest::Approx(qb3.get()));
604603
}
605604

605+
SUBCASE("testing untag") {
606+
quantity_type qa{};
607+
608+
CHECK(typeid(untag(qa)) == typeid(quantity_type));
609+
}
610+
606611
SUBCASE("testing quantity_cast") {
607612
using test_qdka = quantity<default_test_unit, kilo_scaling, double, tag_t<struct tag_a>>;
608613
using test_qika = quantity<default_test_unit, kilo_scaling, int , tag_t<struct tag_a>>;

0 commit comments

Comments
 (0)