Skip to content

Commit d107a95

Browse files
committed
Datatype helpers: non-template variants
1 parent 219e1d8 commit d107a95

1 file changed

Lines changed: 28 additions & 11 deletions

File tree

include/openPMD/Datatype.hpp

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ template <typename T>
294294
inline constexpr Datatype determineDatatype(T &&val)
295295
{
296296
(void)val; // don't need this, it only has a name for Doxygen
297-
using T_stripped = std::remove_cv_t<std::remove_reference_t<T>>;
297+
using T_stripped =
298+
std::remove_extent_t<std::remove_cv_t<std::remove_reference_t<T>>>;
298299
if constexpr (auxiliary::IsPointer_v<T_stripped>)
299300
{
300301
return determineDatatype<auxiliary::IsPointer_t<T_stripped>>();
@@ -595,14 +596,19 @@ inline std::tuple<bool, bool> isInteger()
595596
*/
596597
template <typename T_FP>
597598
inline bool isSameFloatingPoint(Datatype d)
599+
{
600+
return isSameFloatingPoint(d, determineDatatype<T_FP>());
601+
}
602+
603+
inline bool isSameFloatingPoint(Datatype d1, Datatype d2)
598604
{
599605
// template
600-
bool tt_is_fp = isFloatingPoint<T_FP>();
606+
bool tt_is_fp = isFloatingPoint(d1);
601607

602608
// Datatype
603-
bool dt_is_fp = isFloatingPoint(d);
609+
bool dt_is_fp = isFloatingPoint(d2);
604610

605-
if (tt_is_fp && dt_is_fp && toBits(d) == toBits(determineDatatype<T_FP>()))
611+
if (tt_is_fp && dt_is_fp && toBits(d1) == toBits(d2))
606612
return true;
607613
else
608614
return false;
@@ -617,15 +623,19 @@ inline bool isSameFloatingPoint(Datatype d)
617623
*/
618624
template <typename T_CFP>
619625
inline bool isSameComplexFloatingPoint(Datatype d)
626+
{
627+
return isSameComplexFloatingPoint(d, determineDatatype<T_CFP>());
628+
}
629+
630+
inline bool isSameComplexFloatingPoint(Datatype d1, Datatype d2)
620631
{
621632
// template
622-
bool tt_is_cfp = isComplexFloatingPoint<T_CFP>();
633+
bool tt_is_cfp = isComplexFloatingPoint(d1);
623634

624635
// Datatype
625-
bool dt_is_cfp = isComplexFloatingPoint(d);
636+
bool dt_is_cfp = isComplexFloatingPoint(d2);
626637

627-
if (tt_is_cfp && dt_is_cfp &&
628-
toBits(d) == toBits(determineDatatype<T_CFP>()))
638+
if (tt_is_cfp && dt_is_cfp && toBits(d1) == toBits(d2))
629639
return true;
630640
else
631641
return false;
@@ -640,17 +650,22 @@ inline bool isSameComplexFloatingPoint(Datatype d)
640650
*/
641651
template <typename T_Int>
642652
inline bool isSameInteger(Datatype d)
653+
{
654+
return isSameInteger(d, determineDatatype<T_Int>());
655+
}
656+
657+
inline bool isSameInteger(Datatype d1, Datatype d2)
643658
{
644659
// template
645660
bool tt_is_int, tt_is_sig;
646-
std::tie(tt_is_int, tt_is_sig) = isInteger<T_Int>();
661+
std::tie(tt_is_int, tt_is_sig) = isInteger(d1);
647662

648663
// Datatype
649664
bool dt_is_int, dt_is_sig;
650-
std::tie(dt_is_int, dt_is_sig) = isInteger(d);
665+
std::tie(dt_is_int, dt_is_sig) = isInteger(d2);
651666

652667
if (tt_is_int && dt_is_int && tt_is_sig == dt_is_sig &&
653-
toBits(d) == toBits(determineDatatype<T_Int>()))
668+
toBits(d1) == toBits(d2))
654669
return true;
655670
else
656671
return false;
@@ -691,6 +706,8 @@ constexpr bool isChar(Datatype d)
691706
template <typename T_Char>
692707
constexpr bool isSameChar(Datatype d);
693708

709+
constexpr bool isSameChar(Datatype d1, Datatype d2);
710+
694711
/** Comparison for two Datatypes
695712
*
696713
* Besides returning true for the same types, identical implementations on

0 commit comments

Comments
 (0)