Skip to content

Commit

Permalink
Block: add std::complex as a special case in reflFirstTypeName
Browse files Browse the repository at this point in the history
This makes reflFirstTypeName<std::complex<float>>() return
"std::complex<float>"s instead of "std::complex<T>"s, and likewise
for std::complex<double>.

Signed-off-by: Daniel Estévez <[email protected]>
  • Loading branch information
daniestevez authored and drslebedev committed Sep 30, 2024
1 parent f94b029 commit 92a08d9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/include/gnuradio-4.0/Block.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1974,6 +1974,8 @@ std::string reflFirstTypeName() {
return fmt::format("gr::DataSet<{}>", reflFirstTypeName<typename Type::value_type>());
} else if constexpr (UncertainValueLike<Type>) {
return fmt::format("gr::UncertainValue<{}>", reflFirstTypeName<typename Type::value_type>());
} else if constexpr (pmtv::Complex<Type>) {
return fmt::format("std::complex<{}>", reflFirstTypeName<typename Type::value_type>());
} else if constexpr (refl::is_reflectable<Type>()) {
return refl::reflect<Type>().name.str();

Expand Down
14 changes: 14 additions & 0 deletions core/test/qa_Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,4 +897,18 @@ const boost::ut::suite<"Requested Work Tests"> _requestedWorkTests = [] {
expect(eq(resultSink.performed_work, 100UZ));
};
};

const boost::ut::suite<"reflFirstTypeName Tests"> _reflFirstTypeNameTests = [] {
using namespace boost::ut;
using namespace gr::detail;
using namespace std::literals::string_literals;

"std::complex"_test = []() {
expect(eq(reflFirstTypeName<std::complex<double>>(),
"std::complex<double>"s));
expect(eq(reflFirstTypeName<std::complex<float>>(),
"std::complex<float>"s));
};
};

int main() { /* not needed for UT */ }

0 comments on commit 92a08d9

Please sign in to comment.