Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 11 additions & 7 deletions stl/inc/array
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ template <class _First, class... _Rest>
array(_First, _Rest...) -> array<typename _Enforce_same<_First, _Rest...>::type, 1 + sizeof...(_Rest)>;
#endif // _HAS_CXX17

struct _Empty_array_element {};

template <class _Ty>
class array<_Ty, 0> {
public:
Expand Down Expand Up @@ -728,47 +730,47 @@ public:
_STL_REPORT_ERROR("array subscript out of range");
#endif // _CONTAINER_DEBUG_LEVEL > 0

return _Elems[0];
return *data();
}

_NODISCARD const_reference operator[](size_type) const noexcept /* strengthened */ {
#if _CONTAINER_DEBUG_LEVEL > 0
_STL_REPORT_ERROR("array subscript out of range");
#endif // _CONTAINER_DEBUG_LEVEL > 0

return _Elems[0];
return *data();
}

_NODISCARD reference front() noexcept /* strengthened */ {
#if _CONTAINER_DEBUG_LEVEL > 0
_STL_REPORT_ERROR("array<T, 0>::front() invalid");
#endif // _CONTAINER_DEBUG_LEVEL > 0

return _Elems[0];
return *data();
}

_NODISCARD const_reference front() const noexcept /* strengthened */ {
#if _CONTAINER_DEBUG_LEVEL > 0
_STL_REPORT_ERROR("array<T, 0>::front() invalid");
#endif // _CONTAINER_DEBUG_LEVEL > 0

return _Elems[0];
return *data();
}

_NODISCARD reference back() noexcept /* strengthened */ {
#if _CONTAINER_DEBUG_LEVEL > 0
_STL_REPORT_ERROR("array<T, 0>::back() invalid");
#endif // _CONTAINER_DEBUG_LEVEL > 0

return _Elems[0];
return *data();
}

_NODISCARD const_reference back() const noexcept /* strengthened */ {
#if _CONTAINER_DEBUG_LEVEL > 0
_STL_REPORT_ERROR("array<T, 0>::back() invalid");
#endif // _CONTAINER_DEBUG_LEVEL > 0

return _Elems[0];
return *data();
}

_NODISCARD _CONSTEXPR17 _Ty* data() noexcept {
Expand All @@ -783,7 +785,9 @@ public:
_Xout_of_range("invalid array<T, 0> subscript");
}

_Ty _Elems[1];
conditional_t<disjunction_v<is_default_constructible<_Ty>, _Is_implicitly_default_constructible<_Ty>>, _Ty,
_Empty_array_element>
_Elems[1];
};

template <class _Ty, size_t _Size, enable_if_t<_Size == 0 || _Is_swappable<_Ty>::value, int> = 0>
Expand Down
10 changes: 3 additions & 7 deletions tests/libcxx/expected_results.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ std/language.support/support.limits/support.limits.general/concepts.version.pass
# Bogus test believes that optional<non_constexpr_destructor> cannot be a literal type
std/utilities/optional/optional.object/optional.object.dtor/dtor.pass.cpp:0 FAIL

# Bogus test believes that copyability of array<T, 0> must be the same as array<T, 1>
std/containers/sequences/array/array.cons/implicit_copy.pass.cpp FAIL


# *** INTERACTIONS WITH CONTEST / C1XX THAT UPSTREAM LIKELY WON'T FIX ***
# Tracked by VSO-593630 "<filesystem> Enable libcxx filesystem tests"
Expand Down Expand Up @@ -348,13 +351,6 @@ std/input.output/file.streams/fstreams/filebuf.virtuals/underflow.pass.cpp FAIL
std/containers/sequences/array/array.fill/fill.fail.cpp FAIL
std/containers/sequences/array/array.swap/swap.fail.cpp FAIL

# GH-942 <array>: std::array<T,0> doesn't compile - when type is not default constructible
std/containers/sequences/array/array.cons/implicit_copy.pass.cpp FAIL
std/containers/sequences/array/array.cons/initialization.pass.cpp FAIL
std/containers/sequences/array/array.data/data_const.pass.cpp FAIL
std/containers/sequences/array/array.data/data.pass.cpp FAIL
std/containers/sequences/array/iterators.pass.cpp FAIL

# GH-1006 <algorithm>: debug checks for predicates are observable
std/algorithms/alg.sorting/alg.merge/inplace_merge_comp.pass.cpp FAIL
std/algorithms/alg.sorting/alg.min.max/minmax_init_list_comp.pass.cpp FAIL
Expand Down
10 changes: 3 additions & 7 deletions tests/libcxx/skipped_tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ language.support\support.limits\support.limits.general\concepts.version.pass.cpp
# Bogus test believes that optional<non_constexpr_destructor> cannot be a literal type
utilities\optional\optional.object\optional.object.dtor\dtor.pass.cpp

# Bogus test believes that copyability of array<T, 0> must be the same as array<T, 1>
containers\sequences\array\array.cons\implicit_copy.pass.cpp


# *** INTERACTIONS WITH CONTEST / C1XX THAT UPSTREAM LIKELY WON'T FIX ***
# Tracked by VSO-593630 "<filesystem> Enable libcxx filesystem tests"
Expand Down Expand Up @@ -348,13 +351,6 @@ input.output\file.streams\fstreams\filebuf.virtuals\underflow.pass.cpp
containers\sequences\array\array.fill\fill.fail.cpp
containers\sequences\array\array.swap\swap.fail.cpp

# GH-942 <array>: std::array<T,0> doesn't compile - when type is not default constructible
containers\sequences\array\array.cons\implicit_copy.pass.cpp
containers\sequences\array\array.cons\initialization.pass.cpp
containers\sequences\array\array.data\data_const.pass.cpp
containers\sequences\array\array.data\data.pass.cpp
containers\sequences\array\iterators.pass.cpp

# GH-1006 <algorithm>: debug checks for predicates are observable
algorithms\alg.sorting\alg.merge\inplace_merge_comp.pass.cpp
algorithms\alg.sorting\alg.min.max\minmax_init_list_comp.pass.cpp
Expand Down