Skip to content

[libc++][type_traits] P2674R1: A trait for implicit lifetime types #106870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
31240ba
[libc++][type_traits] P2647R1: A trait for implicit lifetime types
H-G-Hristov Aug 24, 2024
c8ae04b
Cleanup + FTM
H-G-Hristov Aug 31, 2024
25e6e5e
Address a review comment
H-G-Hristov Sep 3, 2024
0f2e4ed
Merge branch 'main' into hgh/libcxx/P2647R1-A-trait-for-implicit-life…
Zingam Sep 3, 2024
b1eb87a
Addressed review comments
H-G-Hristov Sep 5, 2024
6038351
Merge branch 'main' into hgh/libcxx/P2647R1-A-trait-for-implicit-life…
Zingam Sep 5, 2024
db95d1d
Addressed philnik's comment
H-G-Hristov Sep 5, 2024
3bd2f8f
Merge branch 'main' into hgh/libcxx/P2647R1-A-trait-for-implicit-life…
Zingam Sep 5, 2024
04f346b
Merge branch 'main' into hgh/libcxx/P2647R1-A-trait-for-implicit-life…
Zingam Sep 5, 2024
69ac1d3
Addressed some comments
H-G-Hristov Sep 8, 2024
bf677ff
Addressed more comments
H-G-Hristov Sep 8, 2024
07695b7
Merge branch 'main' into hgh/libcxx/P2647R1-A-trait-for-implicit-life…
Zingam Sep 8, 2024
dab49b8
Used `types::for_each` in tests
H-G-Hristov Oct 7, 2024
ab0c4ea
Merge branch 'main' into hgh/libcxx/P2647R1-A-trait-for-implicit-life…
H-G-Hristov Oct 7, 2024
a4c4bca
Fixed `module.modulemap`
H-G-Hristov Oct 7, 2024
11f9489
Update libcxx/docs/ReleaseNotes/20.rst
Zingam Oct 7, 2024
2b478fb
Test atomic
H-G-Hristov Oct 8, 2024
647b10a
Cleanup
H-G-Hristov Oct 8, 2024
ddc5ddd
Merge branch 'main' into hgh/libcxx/P2647R1-A-trait-for-implicit-life…
Zingam Oct 8, 2024
13e4470
Addressed review comment
H-G-Hristov Oct 8, 2024
9481ae4
Merge branch 'main' into hgh/libcxx/P2647R1-A-trait-for-implicit-life…
Zingam Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libcxx/docs/FeatureTestMacroTable.rst
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ Status
---------------------------------------------------------- -----------------
``__cpp_lib_ios_noreplace`` ``202207L``
---------------------------------------------------------- -----------------
``__cpp_lib_is_implicit_lifetime`` ``202302L``
---------------------------------------------------------- -----------------
``__cpp_lib_is_scoped_enum`` ``202011L``
---------------------------------------------------------- -----------------
``__cpp_lib_mdspan`` ``202207L``
Expand Down
1 change: 1 addition & 0 deletions libcxx/docs/ReleaseNotes/20.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Implemented Papers
- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
- P2985R0: A type trait for detecting virtual base classes (`Github <https://github.com/llvm/llvm-project/issues/105432>`__)
- ``std::jthread`` and ``<stop_token>`` are not guarded behind ``-fexperimental-library`` anymore
- P2674R1: A trait for implicit lifetime types (`Github <https://github.com/llvm/llvm-project/issues/105259>`__)

Improvements and New Features
-----------------------------
Expand Down
2 changes: 1 addition & 1 deletion libcxx/docs/Status/Cxx23Papers.csv
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"`P2572R1 <https://wg21.link/P2572R1>`__","``std::format`` fill character allowances","2023-02 (Issaquah)","|Complete|","17.0",""
"`P2693R1 <https://wg21.link/P2693R1>`__","Formatting ``thread::id`` and ``stacktrace``","2023-02 (Issaquah)","|Partial|","","The formatter for ``stacktrace`` is not implemented, since ``stacktrace`` is not implemented yet"
"`P2679R2 <https://wg21.link/P2679R2>`__","Fixing ``std::start_lifetime_as`` for arrays","2023-02 (Issaquah)","","",""
"`P2674R1 <https://wg21.link/P2674R1>`__","A trait for implicit lifetime types","2023-02 (Issaquah)","","",""
"`P2674R1 <https://wg21.link/P2674R1>`__","A trait for implicit lifetime types","2023-02 (Issaquah)","|Complete|","20.0",""
"`P2655R3 <https://wg21.link/P2655R3>`__","``common_reference_t`` of ``reference_wrapper`` Should Be a Reference Type","2023-02 (Issaquah)","","",""
"`P2652R2 <https://wg21.link/P2652R2>`__","Disallow User Specialization of ``allocator_traits``","2023-02 (Issaquah)","|Complete|","19.0",""
"`P2787R1 <https://wg21.link/P2787R1>`__","``pmr::generator`` - Promise Types are not Values","2023-02 (Issaquah)","","",""
Expand Down
1 change: 1 addition & 0 deletions libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ set(files
__type_traits/is_floating_point.h
__type_traits/is_function.h
__type_traits/is_fundamental.h
__type_traits/is_implicit_lifetime.h
__type_traits/is_implicitly_default_constructible.h
__type_traits/is_integral.h
__type_traits/is_literal_type.h
Expand Down
35 changes: 35 additions & 0 deletions libcxx/include/__type_traits/is_implicit_lifetime.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//===----------------------------------------------------------------------===//
//
// 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_IMPLICIT_LIFETIME_H
#define _LIBCPP___TYPE_TRAITS_IS_IMPLICIT_LIFETIME_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 >= 23
# if __has_builtin(__builtin_is_implicit_lifetime)

template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS is_implicit_lifetime : public bool_constant<__builtin_is_implicit_lifetime(_Tp)> {};

template <class _Tp>
inline constexpr bool is_implicit_lifetime_v = __builtin_is_implicit_lifetime(_Tp);

# endif
#endif

_LIBCPP_END_NAMESPACE_STD

#endif // _LIBCPP___TYPE_TRAITS_IS_IMPLICIT_LIFETIME_H
4 changes: 4 additions & 0 deletions libcxx/include/module.modulemap
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,10 @@ module std_core [system] {
header "__type_traits/is_fundamental.h"
export std_core.type_traits.integral_constant
}
module is_implicit_lifetime {
header "__type_traits/is_implicit_lifetime.h"
export std_core.type_traits.integral_constant
}
module is_implicitly_default_constructible {
header "__type_traits/is_implicitly_default_constructible.h"
export std_core.type_traits.integral_constant
Expand Down
8 changes: 8 additions & 0 deletions libcxx/include/type_traits
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ namespace std
template <class T> struct is_nothrow_swappable; // C++17
template <class T> struct is_nothrow_destructible;

template<class T> struct is_implicit_lifetime; // Since C++23

template <class T> struct has_virtual_destructor;

template<class T> struct has_unique_object_representations; // C++17
Expand Down Expand Up @@ -374,6 +376,8 @@ namespace std
= is_nothrow_swappable<T>::value; // C++17
template <class T> inline constexpr bool is_nothrow_destructible_v
= is_nothrow_destructible<T>::value; // C++17
template<class T>
constexpr bool is_implicit_lifetime_v = is_implicit_lifetime<T>::value; // Since C++23
template <class T> inline constexpr bool has_virtual_destructor_v
= has_virtual_destructor<T>::value; // C++17
template<class T> inline constexpr bool has_unique_object_representations_v // C++17
Expand Down Expand Up @@ -516,6 +520,10 @@ namespace std
# include <__type_traits/unwrap_ref.h>
#endif

#if _LIBCPP_STD_VER >= 23
# include <__type_traits/is_implicit_lifetime.h>
#endif

#include <version>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Expand Down
4 changes: 4 additions & 0 deletions libcxx/include/version
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ __cpp_lib_ios_noreplace 202207L <ios>
__cpp_lib_is_aggregate 201703L <type_traits>
__cpp_lib_is_constant_evaluated 201811L <type_traits>
__cpp_lib_is_final 201402L <type_traits>
__cpp_lib_is_implicit_lifetime 202302L <type_traits>
__cpp_lib_is_invocable 201703L <type_traits>
__cpp_lib_is_layout_compatible 201907L <type_traits>
__cpp_lib_is_nothrow_convertible 201806L <type_traits>
Expand Down Expand Up @@ -473,6 +474,9 @@ __cpp_lib_void_t 201411L <type_traits>
# define __cpp_lib_forward_like 202207L
# define __cpp_lib_invoke_r 202106L
# define __cpp_lib_ios_noreplace 202207L
# if __has_builtin(__builtin_is_implicit_lifetime)
# define __cpp_lib_is_implicit_lifetime 202302L
# endif
# define __cpp_lib_is_scoped_enum 202011L
# define __cpp_lib_mdspan 202207L
# define __cpp_lib_modules 202207L
Expand Down
8 changes: 6 additions & 2 deletions libcxx/modules/std/type_traits.inc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export namespace std {

using std::is_nothrow_destructible;

// using std::is_implicit_lifetime;
#if _LIBCPP_STD_VER >= 23 && __has_builtin(__builtin_is_implicit_lifetime)
using std::is_implicit_lifetime;
#endif

using std::has_virtual_destructor;

Expand Down Expand Up @@ -246,7 +248,9 @@ export namespace std {
using std::is_destructible_v;
using std::is_empty_v;
using std::is_final_v;
// using std::is_implicit_lifetime_v;
#if _LIBCPP_STD_VER >= 23 && __has_builtin(__builtin_is_implicit_lifetime)
using std::is_implicit_lifetime_v;
#endif
using std::is_move_assignable_v;
using std::is_move_constructible_v;
using std::is_nothrow_assignable_v;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
__cpp_lib_is_aggregate 201703L [C++17]
__cpp_lib_is_constant_evaluated 201811L [C++20]
__cpp_lib_is_final 201402L [C++14]
__cpp_lib_is_implicit_lifetime 202302L [C++23]
__cpp_lib_is_invocable 201703L [C++17]
__cpp_lib_is_layout_compatible 201907L [C++20]
__cpp_lib_is_nothrow_convertible 201806L [C++20]
Expand Down Expand Up @@ -75,6 +76,10 @@
# error "__cpp_lib_is_final should not be defined before c++14"
# endif

# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
# endif

# ifdef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should not be defined before c++17"
# endif
Expand Down Expand Up @@ -179,6 +184,10 @@
# error "__cpp_lib_is_final should have the value 201402L in c++14"
# endif

# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
# endif

# ifdef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should not be defined before c++17"
# endif
Expand Down Expand Up @@ -301,6 +310,10 @@
# error "__cpp_lib_is_final should have the value 201402L in c++17"
# endif

# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
# endif

# ifndef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should be defined in c++17"
# endif
Expand Down Expand Up @@ -444,6 +457,10 @@
# error "__cpp_lib_is_final should have the value 201402L in c++20"
# endif

# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
# endif

# ifndef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should be defined in c++20"
# endif
Expand Down Expand Up @@ -614,6 +631,19 @@
# error "__cpp_lib_is_final should have the value 201402L in c++23"
# endif

# if __has_builtin(__builtin_is_implicit_lifetime)
# ifndef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should be defined in c++23"
# endif
# if __cpp_lib_is_implicit_lifetime != 202302L
# error "__cpp_lib_is_implicit_lifetime should have the value 202302L in c++23"
# endif
# else
# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined when the requirement '__has_builtin(__builtin_is_implicit_lifetime)' is not met!"
# endif
# endif

# ifndef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should be defined in c++23"
# endif
Expand Down Expand Up @@ -796,6 +826,19 @@
# error "__cpp_lib_is_final should have the value 201402L in c++26"
# endif

# if __has_builtin(__builtin_is_implicit_lifetime)
# ifndef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should be defined in c++26"
# endif
# if __cpp_lib_is_implicit_lifetime != 202302L
# error "__cpp_lib_is_implicit_lifetime should have the value 202302L in c++26"
# endif
# else
# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined when the requirement '__has_builtin(__builtin_is_implicit_lifetime)' is not met!"
# endif
# endif

# ifndef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should be defined in c++26"
# endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
__cpp_lib_is_aggregate 201703L [C++17]
__cpp_lib_is_constant_evaluated 201811L [C++20]
__cpp_lib_is_final 201402L [C++14]
__cpp_lib_is_implicit_lifetime 202302L [C++23]
__cpp_lib_is_invocable 201703L [C++17]
__cpp_lib_is_layout_compatible 201907L [C++20]
__cpp_lib_is_nothrow_convertible 201806L [C++20]
Expand Down Expand Up @@ -671,6 +672,10 @@
# error "__cpp_lib_is_final should not be defined before c++14"
# endif

# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
# endif

# ifdef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should not be defined before c++17"
# endif
Expand Down Expand Up @@ -1550,6 +1555,10 @@
# error "__cpp_lib_is_final should have the value 201402L in c++14"
# endif

# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
# endif

# ifdef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should not be defined before c++17"
# endif
Expand Down Expand Up @@ -2564,6 +2573,10 @@
# error "__cpp_lib_is_final should have the value 201402L in c++17"
# endif

# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
# endif

# ifndef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should be defined in c++17"
# endif
Expand Down Expand Up @@ -3842,6 +3855,10 @@
# error "__cpp_lib_is_final should have the value 201402L in c++20"
# endif

# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined before c++23"
# endif

# ifndef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should be defined in c++20"
# endif
Expand Down Expand Up @@ -5306,6 +5323,19 @@
# error "__cpp_lib_is_final should have the value 201402L in c++23"
# endif

# if __has_builtin(__builtin_is_implicit_lifetime)
# ifndef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should be defined in c++23"
# endif
# if __cpp_lib_is_implicit_lifetime != 202302L
# error "__cpp_lib_is_implicit_lifetime should have the value 202302L in c++23"
# endif
# else
# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined when the requirement '__has_builtin(__builtin_is_implicit_lifetime)' is not met!"
# endif
# endif

# ifndef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should be defined in c++23"
# endif
Expand Down Expand Up @@ -7112,6 +7142,19 @@
# error "__cpp_lib_is_final should have the value 201402L in c++26"
# endif

# if __has_builtin(__builtin_is_implicit_lifetime)
# ifndef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should be defined in c++26"
# endif
# if __cpp_lib_is_implicit_lifetime != 202302L
# error "__cpp_lib_is_implicit_lifetime should have the value 202302L in c++26"
# endif
# else
# ifdef __cpp_lib_is_implicit_lifetime
# error "__cpp_lib_is_implicit_lifetime should not be defined when the requirement '__has_builtin(__builtin_is_implicit_lifetime)' is not met!"
# endif
# endif

# ifndef __cpp_lib_is_invocable
# error "__cpp_lib_is_invocable should be defined in c++26"
# endif
Expand Down
Loading