File indexing completed on 2024-05-12 15:57:02

0001 /*
0002  *  SPDX-FileCopyrightText: 2021 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KISHALFTRAITS_H
0008 #define KISHALFTRAITS_H
0009 
0010 #include <KoConfig.h>
0011 #ifdef HAVE_OPENEXR
0012 
0013 #include <half.h>
0014 #include <halfLimits.h>
0015 
0016 #include <type_traits>
0017 
0018 namespace std {
0019 
0020 #if defined __GLIBCXX__
0021 
0022 template<>
0023   struct __is_integral_helper<half>
0024   : public false_type { };
0025 
0026 template<>
0027   struct __is_floating_point_helper<half>
0028   : public true_type { };
0029 
0030 #elif defined _LIBCPP_VERSION
0031 
0032 template<>
0033   struct __libcpp_is_integral<half>
0034   : public false_type { };
0035 
0036 template<>
0037   struct __libcpp_is_floating_point<half>
0038   : public true_type { };
0039 
0040 
0041 #else
0042   // these are fallback implementations that
0043   // don't support cv-qualifiers removal
0044 
0045   template<>
0046   struct is_integral<half>
0047     : public false_type
0048     { };
0049 
0050   template<>
0051   struct is_floating_point<half>
0052     : public true_type
0053     { };
0054 
0055 #endif
0056 
0057   inline bool
0058   isfinite(half __x)
0059   { return __x.isFinite(); }
0060 
0061   inline bool
0062   isinf(half __x)
0063   { return __x.isInfinity(); }
0064 
0065   inline bool
0066   isnan(half __x)
0067   { return __x.isNan(); }
0068 
0069   inline bool
0070   isnormal(half __x)
0071   { return __x.isNormalized(); }
0072 
0073   inline bool
0074   signbit(half __x)
0075   { return __x.isNegative(); }
0076 
0077 }
0078 
0079 #endif
0080 
0081 #endif // KISHALFTRAITS_H