@@ -67,6 +67,11 @@ static_assert(!can_construct_at<const volatile int>);
6767static_assert (!can_construct_at<const volatile int , int >);
6868static_assert (!can_construct_at<const volatile int , int &>);
6969
70+ static_assert (can_construct_at<int [1 ]>);
71+ static_assert (can_construct_at<int [1 ][42 ]>);
72+ static_assert (!can_construct_at<int []>);
73+ static_assert (!can_construct_at<int [][42 ]>);
74+
7075struct X {};
7176
7277static_assert (!can_construct_at<int , X>);
@@ -619,6 +624,72 @@ static_assert(!CanWellDefinedlyAccessAfterOperation<[](auto& arr) { ranges::dest
619624static_assert (!CanWellDefinedlyAccessAfterOperation<[](auto & arr) { ranges::destroy_n (arr + 0 , 1 ); }>);
620625#endif // ^^^ no workaround ^^^
621626
627+ // Test LWG-3436 "std::construct_at should support arrays"
628+ template <class T , size_t N>
629+ constexpr void test_std_construct_at_array () {
630+ union U {
631+ constexpr U () {}
632+ constexpr ~U () {}
633+
634+ T a[N];
635+ };
636+ U u;
637+ construct_at (&u.a );
638+ for (const auto & elem : u.a ) {
639+ assert (elem == T{});
640+ }
641+ destroy_at (&u.a );
642+ }
643+
644+ template <class T , size_t N>
645+ constexpr void test_ranges_construct_at_array () {
646+ union U {
647+ constexpr U () {}
648+ constexpr ~U () {}
649+
650+ T a[N];
651+ };
652+ U u;
653+ ranges::construct_at (&u.a );
654+ for (const auto & elem : u.a ) {
655+ assert (elem == T{});
656+ }
657+ ranges::destroy_at (&u.a );
658+ }
659+
660+ constexpr bool test_construct_at_array () {
661+ test_std_construct_at_array<int , 1 >();
662+ test_std_construct_at_array<int , 42 >();
663+ test_ranges_construct_at_array<int , 1 >();
664+ test_ranges_construct_at_array<int , 42 >();
665+
666+ #if !defined(__clang__) && !defined(__EDG__) // TRANSITION, DevCom-10798069
667+ if (!is_constant_evaluated ())
668+ #endif // ^^^ workaround ^^^
669+ {
670+ #if !_HAS_CXX23
671+ if (!is_constant_evaluated ())
672+ #endif // !_HAS_CXX23
673+ {
674+ test_std_construct_at_array<unique_ptr<string>, 1 >();
675+ test_std_construct_at_array<unique_ptr<string>, 42 >();
676+ test_ranges_construct_at_array<unique_ptr<string>, 1 >();
677+ test_ranges_construct_at_array<unique_ptr<string>, 42 >();
678+ }
679+ test_std_construct_at_array<string, 1 >();
680+ test_ranges_construct_at_array<string, 1 >();
681+ #if defined(__EDG__) && _ITERATOR_DEBUG_LEVEL != 0 // TRANSITION, DevCom-11012299
682+ if (!is_constant_evaluated ())
683+ #endif // ^^^ workaround ^^^
684+ {
685+ test_std_construct_at_array<string, 42 >();
686+ test_ranges_construct_at_array<string, 42 >();
687+ }
688+ }
689+
690+ return true ;
691+ }
692+
622693int main () {
623694 test_runtime (1234 );
624695 test_runtime (string (" hello world" ));
@@ -637,4 +708,7 @@ int main() {
637708 test_array (1234 );
638709 test_array (string (" hello world" ));
639710 test_array (string (" hello to some really long world that certainly doesn't fit in SSO" ));
711+
712+ test_construct_at_array ();
713+ static_assert (test_construct_at_array ());
640714}
0 commit comments