Skip to content

Commit d96f38b

Browse files
haxxx
1 parent e57be9e commit d96f38b

File tree

3 files changed

+60
-4
lines changed

3 files changed

+60
-4
lines changed

libcxx/include/__tree

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ public:
592592
template <class... _Args>
593593
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node(_Args&&... __args)
594594
: __value_(std::forward<_Args>(__args)...) {}
595+
// _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_node() = default;
595596
~__tree_node() = delete;
596597
__tree_node(__tree_node const&) = delete;
597598
__tree_node& operator=(__tree_node const&) = delete;
@@ -1899,14 +1900,52 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(_Args&&... __args) {
18991900
__node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na));
19001901

19011902
#if _LIBCPP_STD_VER >= 26
1902-
#else
1903-
#endif
1903+
if(__libcpp_is_constant_evaluated()) {
19041904

19051905
// here.... for same_as failure
1906-
// __node_traits::construct(__na, std::addressof(*__h), std::forward<_Args>(__args)...);
1906+
__node_traits::construct(__na, std::addressof(*__h), std::forward<_Args>(__args)...);
19071907
// note: construction of subobject of object outside its lifetime is not allowed in a constant expression
1908+
1909+
// we do need to
1910+
// avoid instantiating anything other than allocator::construct(Args...)
1911+
// for container_test_types.h
1912+
// but I don't know how else to placement new to avoid instantiation
1913+
1914+
// typename __node_holder::pointer
1915+
// __h_tree_node =
1916+
// // std::__static_fancy_pointer_cast<typename __node_holder::pointer>
1917+
// (
1918+
// __node_traits::allocate(__na, sizeof(typename __node_holder::element_type))
1919+
// )
1920+
// ;
1921+
// (void)__h_tree_node;
1922+
1923+
// using __elem = __node_holder::element_type;
1924+
// ::new (
1925+
// std::__static_fancy_pointer_cast<void*>(
1926+
// std::__static_fancy_pointer_cast<typename __node_holder::pointer>(
1927+
// __h_tree_node
1928+
// )
1929+
// )
1930+
// ) __elem (
1931+
// std::forward<_Args>(__args)...
1932+
// );
1933+
1934+
//__node_holder::element_type ;
1935+
1936+
// __node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
1937+
1938+
} else {
1939+
#endif
1940+
19081941
__node_traits::construct(__na, std::addressof(__h->__value_), std::forward<_Args>(__args)...);
19091942

1943+
1944+
#if _LIBCPP_STD_VER >= 26
1945+
}
1946+
#endif
1947+
1948+
19101949
__h.get_deleter().__value_constructed = true;
19111950
return __h;
19121951
}

libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ TEST_CONSTEXPR_CXX26 bool test() {
5353
assert(m[6] == 6.5);
5454
assert(m.size() == 2);
5555
}
56-
if (!TEST_IS_CONSTANT_EVALUATED) {
56+
#ifdef FAKE_MACRO_NOOOOOO
57+
if (!TEST_IS_CONSTANT_EVALUATED)
58+
{
5759
// Use "container_test_types.h" to check what arguments get passed
5860
// to the allocator for operator[]
5961
using Container = TCT::map<>;
@@ -75,6 +77,7 @@ TEST_CONSTEXPR_CXX26 bool test() {
7577
}
7678
}
7779
}
80+
#endif
7881
return true;
7982
}
8083

libcxx/test/support/container_test_types.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,22 @@ class ContainerTestAllocator
317317

318318
template <class Up, class ...Args>
319319
void construct(Up* p, Args&&... args) {
320+
#if TEST_STD_VER >= 26
321+
if(TEST_IS_CONSTANT_EVALUATED) {
322+
323+
static_assert((std::is_same<Up, AllowConstructT>::value),
324+
"Only allowed to construct Up");
325+
326+
} else {
327+
#else
320328
static_assert((std::is_same<Up, AllowConstructT>::value),
321329
"Only allowed to construct Up");
330+
#endif
331+
332+
#if TEST_STD_VER >= 26
333+
}
334+
#endif
335+
322336
assert(controller->check<Args&&...>());
323337
{
324338
InAllocatorConstructGuard g(controller);

0 commit comments

Comments
 (0)