/usr/include/sopt/real_type.h is in libsopt-dev 2.0.0-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | #ifndef SOPT_REAL_TYPE_H
#define SOPT_REAL_TYPE_H
#include "sopt/config.h"
#include <complex>
#include <type_traits>
namespace sopt {
namespace details {
// Checks wether a type has contains a type "value_type"
template <class T, class Enable = void> struct HasValueType {
using Have = char[1];
using HaveNot = char[2];
struct Fallback {
struct value_type {};
};
struct Derived : T, Fallback {};
template <class U> static Have &test(typename U::value_type *);
template <typename U> static HaveNot &test(U *);
public:
static constexpr bool value = sizeof(test<Derived>(nullptr)) == sizeof(HaveNot);
};
// Specialization for fundamental type that cannot be derived from
template <class T>
struct HasValueType<T, typename std::enable_if<std::is_fundamental<T>::value>::type>
: std::false_type {};
//! Detects whether a class contains a value_type type
template <class T, bool = details::HasValueType<T>::value> class has_value_type;
template <class T> class has_value_type<T, true> : public std::true_type {};
template <class T> class has_value_type<T, false> : public std::false_type {};
//! Computes inner-most element type
template <class T, bool = has_value_type<T>::value> class underlying_value_type;
template <class T> class underlying_value_type<T, false> {
public:
typedef T type;
};
template <class T> class underlying_value_type<T, true> {
public:
typedef typename underlying_value_type<typename T::value_type>::type type;
};
}
//! Gets to the underlying real type
template <class T> using real_type = details::underlying_value_type<T>;
//! True if underlying type is complex
template <class T, class SP = void> struct is_complex : public std::false_type {};
//! True if underlying type is complex
template <class T> struct is_complex<std::complex<T>, void> : public std::true_type {};
} /* sopt */
#endif
|