[libaxx] Add complex c++ library

This commit is contained in:
Émilie Feral
2018-04-13 14:45:16 +02:00
parent 537cae5839
commit 9fcb22ef8e
7 changed files with 1767 additions and 4 deletions

7
libaxx/include/complex Normal file
View File

@@ -0,0 +1,7 @@
#ifndef LIBAXX_COMPLEX
#define LIBAXX_COMPLEX
#define THINNER_HEADER
#include "external/libcxx/complex"
#endif

1548
libaxx/include/external/libcxx/complex vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
#ifndef LIBAXX_LIBCXX_CONFIG
#define LIBAXX_LIBCXX_CONFIG
#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {
#define _LIBCPP_END_NAMESPACE_STD }
#define _LIBCPP_TEMPLATE_VIS __attribute__ ((__visibility__("default")))
#define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__))
#define _LIBCPP_CONSTEXPR_AFTER_CXX11
#define _LIBCPP_CONSTEXPR_AFTER_CXX14
#define _LIBCPP_CONSTEXPR constexpr
#define __has_feature(__x) 0
#define _LIBCPP_NO_CFI
#define _NOEXCEPT noexcept
#define _NOEXCEPT_(x) noexcept(x)
#define _LIBCPP_HAS_NO_INT128
#define _VSTD std
#define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__))
#endif

View File

@@ -0,0 +1,32 @@
#ifndef LIBAXX_LIBCXX_CMATH
#define LIBAXX_LIBCXX_CMATH
#include_next <cmath>
#include "type_traits"
namespace std {
template <class _A1> inline constexpr typename enable_if<is_floating_point<_A1>::value, bool>::type __libcpp_isnan_or_builtin(_A1 __lcpp_x) noexcept {
return __builtin_isnan(__lcpp_x);
}
template <class _A1> inline constexpr typename enable_if<is_floating_point<_A1>::value, bool>::type __libcpp_isinf_or_builtin(_A1 __lcpp_x) noexcept {
return __builtin_isinf(__lcpp_x);
}
template <class _A1> inline constexpr typename enable_if<is_floating_point<_A1>::value, bool>::type __libcpp_isfinite_or_builtin(_A1 __lcpp_x) noexcept {
return __builtin_isfinite(__lcpp_x);
}
inline float abs(float __lcpp_x) noexcept {
return fabsf(__lcpp_x);
}
inline double abs(double __lcpp_x) noexcept {
return fabs(__lcpp_x);
}
}
#endif

View File

@@ -0,0 +1,147 @@
#ifndef LIBAXX_LIBCXX_TYPE_TRAITS
#define LIBAXX_LIBCXX_TYPE_TRAITS
namespace std {
template <class _Tp> struct remove_const {typedef _Tp type;};
template <class _Tp> struct remove_const<const _Tp> {typedef _Tp type;};
template <class _Tp> struct remove_volatile {typedef _Tp type;};
template <class _Tp> struct remove_volatile<volatile _Tp> {typedef _Tp type;};
template <class _Tp> struct remove_cv {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;};
template <class _Tp, _Tp __v>
struct integral_constant
{
static constexpr const _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant type;
inline constexpr operator value_type() const noexcept {return value;}
};
typedef integral_constant<bool,(true)> true_type;
typedef integral_constant<bool,(false)> false_type;
// is_integral
template <class _Tp> struct __libcpp_is_integral : public false_type {};
template <> struct __libcpp_is_integral<bool> : public true_type {};
template <> struct __libcpp_is_integral<char> : public true_type {};
template <> struct __libcpp_is_integral<signed char> : public true_type {};
template <> struct __libcpp_is_integral<unsigned char> : public true_type {};
template <> struct __libcpp_is_integral<wchar_t> : public true_type {};
template <> struct __libcpp_is_integral<short> : public true_type {};
template <> struct __libcpp_is_integral<unsigned short> : public true_type {};
template <> struct __libcpp_is_integral<int> : public true_type {};
template <> struct __libcpp_is_integral<unsigned int> : public true_type {};
template <> struct __libcpp_is_integral<long> : public true_type {};
template <> struct __libcpp_is_integral<unsigned long> : public true_type {};
template <> struct __libcpp_is_integral<long long> : public true_type {};
template <> struct __libcpp_is_integral<unsigned long long> : public true_type {};
template <class _Tp> struct is_integral : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {};
// is_floating_point
template <class _Tp> struct __libcpp_is_floating_point : public false_type {};
template <> struct __libcpp_is_floating_point<float> : public true_type {};
template <> struct __libcpp_is_floating_point<double> : public true_type {};
template <class _Tp> struct is_floating_point : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {};
// enable_if
template <bool, class _Tp = void> struct enable_if {};
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS enable_if<true, _Tp> {typedef _Tp type;};
// is_same
template <class _Tp, class _Up> struct is_same : public false_type {};
template <class _Tp> struct is_same<_Tp, _Tp> : public true_type {};
// declval
template <class _Tp> struct add_rvalue_reference {typedef _Tp&& type;};
template <> struct add_rvalue_reference<void> {typedef void type;};
template <> struct add_rvalue_reference<const void> {typedef const void type;};
template <> struct add_rvalue_reference<volatile void> {typedef volatile void type;};
template <> struct add_rvalue_reference<const volatile void> {typedef const volatile void type;};
template <class _Tp> typename add_rvalue_reference<_Tp>::type declval() noexcept;
//__numeric_type
template <class _Tp>
struct __numeric_type
{
static void __test(...);
static float __test(float);
static double __test(char);
static double __test(int);
static double __test(unsigned);
static double __test(long);
static double __test(unsigned long);
static double __test(long long);
static double __test(unsigned long long);
static double __test(double);
typedef decltype(__test(declval<_Tp>())) type;
static const bool value = !is_same<type, void>::value;
};
template <>
struct __numeric_type<void>
{
static const bool value = true;
};
// __promote
template <class _A1, class _A2 = void, class _A3 = void,
bool = __numeric_type<_A1>::value &&
__numeric_type<_A2>::value &&
__numeric_type<_A3>::value>
class __promote_imp
{
public:
static const bool value = false;
};
template <class _A1, class _A2, class _A3>
class __promote_imp<_A1, _A2, _A3, true>
{
private:
typedef typename __promote_imp<_A1>::type __type1;
typedef typename __promote_imp<_A2>::type __type2;
typedef typename __promote_imp<_A3>::type __type3;
public:
typedef decltype(__type1() + __type2() + __type3()) type;
static const bool value = true;
};
template <class _A1, class _A2>
class __promote_imp<_A1, _A2, void, true>
{
private:
typedef typename __promote_imp<_A1>::type __type1;
typedef typename __promote_imp<_A2>::type __type2;
public:
typedef decltype(__type1() + __type2()) type;
static const bool value = true;
};
template <class _A1>
class __promote_imp<_A1, void, void, true>
{
public:
typedef typename __numeric_type<_A1>::type type;
static const bool value = true;
};
template <class _A1, class _A2 = void, class _A3 = void>
class __promote : public __promote_imp<_A1, _A2, _A3> {};
// is_arithmetic
template <class _Tp> struct is_arithmetic : public integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {};
}
#endif

View File

@@ -0,0 +1,12 @@
#ifndef LIBAXX_TYPE_TRAITS
#define LIBAXX_TYPE_TRAITS
namespace std {
template <class T> struct remove_reference {typedef T type;};
template <class T> struct remove_reference<T&> {typedef T type;};
template <class T> struct remove_reference<T&&> {typedef T type;};
}
#endif

View File

@@ -1,11 +1,9 @@
#ifndef LIBAXX_UTILITY #ifndef LIBAXX_UTILITY
#define LIBAXX_UTILITY #define LIBAXX_UTILITY
namespace std { #include <type_traits>
template <class T> struct remove_reference {typedef T type;}; namespace std {
template <class T> struct remove_reference<T&> {typedef T type;};
template <class T> struct remove_reference<T&&> {typedef T type;};
template <class T> typename remove_reference<T>::type&& move(T&& a) { template <class T> typename remove_reference<T>::type&& move(T&& a) {
return (typename remove_reference<T>::type&&)a; return (typename remove_reference<T>::type&&)a;