Skip to content

Commit 5bcb59a

Browse files
committed
Avoid using constexpr where C++03 will hate it
Another CI failure occurred because of compiling in C++03 mode, where 'constexpr' isn't even a keyword. Replaced with _LIBCPP_CONSTEXPR_SINCE_20 where feasible, and enum otherwise.
1 parent 911d9ad commit 5bcb59a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

libcxx/include/string

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -719,15 +719,15 @@ struct __init_with_sentinel_tag {};
719719
template <size_t _PaddingSize>
720720
struct __padding {
721721
char __padding_[_PaddingSize];
722-
static constexpr __padding empty() {
722+
static _LIBCPP_CONSTEXPR_SINCE_CXX20 __padding empty() {
723723
__padding __initialized = {0};
724724
return __initialized;
725725
}
726726
};
727727

728728
template <>
729729
struct __padding<0> {
730-
static constexpr __padding empty() {
730+
static _LIBCPP_CONSTEXPR_SINCE_CXX20 __padding empty() {
731731
__padding __initialized;
732732
return __initialized;
733733
}
@@ -840,17 +840,17 @@ private:
840840
// The __short structure has a byte-sized bitfield container at the end, and
841841
// the rest of it can be taken up by value_type. We want at least two
842842
// value_type, or more if they will fit.
843-
static constexpr size_t __fit_cap = (sizeof(__long_min) - 1) / sizeof(value_type);
844-
static constexpr size_t __min_cap = __fit_cap > 2 ? __fit_cap : 2;
843+
enum { __fit_cap = (sizeof(__long_min) - 1) / sizeof(value_type) };
844+
enum { __min_cap = __fit_cap > 2 ? __fit_cap : 2 };
845845

846846
// Now we know how many value_type will fit, calculate how much space they
847847
// take up in total; add one byte for the final bitfield container; and round
848848
// up to the nearest multiple of the alignment. That's the total size of the
849849
// structure.
850-
static constexpr size_t __short_packed_size = sizeof(value_type) * __min_cap + 1;
850+
enum { __short_packed_size = sizeof(value_type) * __min_cap + 1 };
851851
union __union_alignment_check { __long_min __long_; value_type v; };
852-
static constexpr size_t __union_alignment = _LIBCPP_ALIGNOF(__union_alignment_check);
853-
static constexpr size_t __full_size = (__short_packed_size + __union_alignment - 1) & -__union_alignment;
852+
enum { __union_alignment = _LIBCPP_ALIGNOF(__union_alignment_check) };
853+
enum { __full_size = (__short_packed_size + __union_alignment - 1) & -__union_alignment };
854854

855855
// Now define both structures for real, with padding to ensure they are both
856856
// exactly the calculated size.

0 commit comments

Comments
 (0)