Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++] Granularize more of <type_traits>
Reviewed By: ldionne, #libc Spies: libcxx-commits, mgorny Differential Revision: https://reviews.llvm.org/D126244
- Loading branch information
1 parent
34f7380
commit 30c37fb
Showing
32 changed files
with
1,295 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_ADD_CONST_H | ||
#define _LIBCPP___TYPE_TRAITS_ADD_CONST_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_const { | ||
typedef _LIBCPP_NODEBUG const _Tp type; | ||
}; | ||
|
||
#if _LIBCPP_STD_VER > 11 | ||
template <class _Tp> using add_const_t = typename add_const<_Tp>::type; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_ADD_CONST_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_ADD_CV_H | ||
#define _LIBCPP___TYPE_TRAITS_ADD_CV_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_cv { | ||
typedef _LIBCPP_NODEBUG const volatile _Tp type; | ||
}; | ||
|
||
#if _LIBCPP_STD_VER > 11 | ||
template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_ADD_CV_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | ||
#define _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H | ||
|
||
#include <__config> | ||
#include <__type_traits/is_referenceable.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_lvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; | ||
template <class _Tp > struct __add_lvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp& type; }; | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_lvalue_reference | ||
{typedef _LIBCPP_NODEBUG typename __add_lvalue_reference_impl<_Tp>::type type;}; | ||
|
||
#if _LIBCPP_STD_VER > 11 | ||
template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_ADD_LVALUE_REFERENCE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | ||
#define _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H | ||
|
||
#include <__config> | ||
#include <__type_traits/is_referenceable.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Tp, bool = __is_referenceable<_Tp>::value> struct __add_rvalue_reference_impl { typedef _LIBCPP_NODEBUG _Tp type; }; | ||
template <class _Tp > struct __add_rvalue_reference_impl<_Tp, true> { typedef _LIBCPP_NODEBUG _Tp&& type; }; | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_rvalue_reference | ||
{typedef _LIBCPP_NODEBUG typename __add_rvalue_reference_impl<_Tp>::type type;}; | ||
|
||
#if _LIBCPP_STD_VER > 11 | ||
template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_ADD_RVALUE_REFERENCE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H | ||
#define _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS add_volatile { | ||
typedef _LIBCPP_NODEBUG volatile _Tp type; | ||
}; | ||
|
||
#if _LIBCPP_STD_VER > 11 | ||
template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_ADD_VOLATILE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_EXTENT_H | ||
#define _LIBCPP___TYPE_TRAITS_EXTENT_H | ||
|
||
#include <__config> | ||
#include <__type_traits/integral_constant.h> | ||
#include <cstddef> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if __has_keyword(__array_extent) | ||
|
||
template<class _Tp, size_t _Dim = 0> | ||
struct _LIBCPP_TEMPLATE_VIS extent | ||
: integral_constant<size_t, __array_extent(_Tp, _Dim)> { }; | ||
|
||
#if _LIBCPP_STD_VER > 14 | ||
template <class _Tp, unsigned _Ip = 0> | ||
inline constexpr size_t extent_v = __array_extent(_Tp, _Ip); | ||
#endif | ||
|
||
#else // __has_keyword(__array_extent) | ||
|
||
template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TEMPLATE_VIS extent | ||
: public integral_constant<size_t, 0> {}; | ||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], 0> | ||
: public integral_constant<size_t, 0> {}; | ||
template <class _Tp, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[], _Ip> | ||
: public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; | ||
template <class _Tp, size_t _Np> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], 0> | ||
: public integral_constant<size_t, _Np> {}; | ||
template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TEMPLATE_VIS extent<_Tp[_Np], _Ip> | ||
: public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; | ||
|
||
#if _LIBCPP_STD_VER > 14 | ||
template <class _Tp, unsigned _Ip = 0> | ||
inline constexpr size_t extent_v = extent<_Tp, _Ip>::value; | ||
#endif | ||
|
||
#endif // __has_keyword(__array_extent) | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_EXTENT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H | ||
#define _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H | ||
|
||
#include <__config> | ||
#include <__type_traits/integral_constant.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_abstract | ||
: public integral_constant<bool, __is_abstract(_Tp)> {}; | ||
|
||
#if _LIBCPP_STD_VER > 14 | ||
template <class _Tp> | ||
inline constexpr bool is_abstract_v = is_abstract<_Tp>::value; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_IS_ABSTRACT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H | ||
#define _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H | ||
|
||
#include <__config> | ||
#include <__type_traits/integral_constant.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 14 | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS | ||
is_aggregate : public integral_constant<bool, __is_aggregate(_Tp)> {}; | ||
|
||
template <class _Tp> | ||
inline constexpr bool is_aggregate_v = is_aggregate<_Tp>::value; | ||
|
||
#endif // _LIBCPP_STD_VER > 14 | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_IS_AGGREGATE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H | ||
#define _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H | ||
|
||
#include <__config> | ||
#include <__type_traits/integral_constant.h> | ||
#include <__type_traits/is_floating_point.h> | ||
#include <__type_traits/is_integral.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Tp> struct _LIBCPP_TEMPLATE_VIS is_arithmetic | ||
: public integral_constant<bool, is_integral<_Tp>::value || | ||
is_floating_point<_Tp>::value> {}; | ||
|
||
#if _LIBCPP_STD_VER > 14 | ||
template <class _Tp> | ||
inline constexpr bool is_arithmetic_v = is_arithmetic<_Tp>::value; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___TYPE_TRAITS_IS_ARITHMETIC_H |
Oops, something went wrong.