Skip to content

Commit b69ddbc

Browse files
authoredNov 13, 2024··
[libc++] Make variables in templates inline (#115785)
The variables are all `constexpr`, which implies `inline`. Since they aren't `constexpr` in C++03 they're also not `inline` there. Because of that we define them out-of-line currently. Instead we can use the C++17 extension of `inline` variables, which results in the same weak definitions of the variables but without having all the boilerplate.
1 parent 889b3c9 commit b69ddbc

14 files changed

+64
-474
lines changed
 

‎libcxx/include/__random/discard_block_engine.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine {
4343
typedef typename _Engine::result_type result_type;
4444

4545
// engine characteristics
46-
static _LIBCPP_CONSTEXPR const size_t block_size = __p;
47-
static _LIBCPP_CONSTEXPR const size_t used_block = __r;
46+
static inline _LIBCPP_CONSTEXPR const size_t block_size = __p;
47+
static inline _LIBCPP_CONSTEXPR const size_t used_block = __r;
4848

4949
#ifdef _LIBCPP_CXX03_LANG
5050
static const result_type _Min = _Engine::_Min;
@@ -110,12 +110,6 @@ class _LIBCPP_TEMPLATE_VIS discard_block_engine {
110110
operator>>(basic_istream<_CharT, _Traits>& __is, discard_block_engine<_Eng, _Pp, _Rp>& __x);
111111
};
112112

113-
template <class _Engine, size_t __p, size_t __r>
114-
_LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::block_size;
115-
116-
template <class _Engine, size_t __p, size_t __r>
117-
_LIBCPP_CONSTEXPR const size_t discard_block_engine<_Engine, __p, __r>::used_block;
118-
119113
template <class _Engine, size_t __p, size_t __r>
120114
typename discard_block_engine<_Engine, __p, __r>::result_type discard_block_engine<_Engine, __p, __r>::operator()() {
121115
if (__n_ >= static_cast<int>(__r)) {

‎libcxx/include/__random/linear_congruential_engine.h

+4-20
Original file line numberDiff line numberDiff line change
@@ -251,12 +251,12 @@ class _LIBCPP_TEMPLATE_VIS linear_congruential_engine {
251251
static_assert(_Min < _Max, "linear_congruential_engine invalid parameters");
252252

253253
// engine characteristics
254-
static _LIBCPP_CONSTEXPR const result_type multiplier = __a;
255-
static _LIBCPP_CONSTEXPR const result_type increment = __c;
256-
static _LIBCPP_CONSTEXPR const result_type modulus = __m;
254+
static inline _LIBCPP_CONSTEXPR const result_type multiplier = __a;
255+
static inline _LIBCPP_CONSTEXPR const result_type increment = __c;
256+
static inline _LIBCPP_CONSTEXPR const result_type modulus = __m;
257257
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
258258
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
259-
static _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
259+
static inline _LIBCPP_CONSTEXPR const result_type default_seed = 1u;
260260

261261
// constructors and seeding functions
262262
#ifndef _LIBCPP_CXX03_LANG
@@ -318,22 +318,6 @@ class _LIBCPP_TEMPLATE_VIS linear_congruential_engine {
318318
operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x);
319319
};
320320

321-
template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
322-
_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
323-
linear_congruential_engine<_UIntType, __a, __c, __m>::multiplier;
324-
325-
template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
326-
_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
327-
linear_congruential_engine<_UIntType, __a, __c, __m>::increment;
328-
329-
template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
330-
_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
331-
linear_congruential_engine<_UIntType, __a, __c, __m>::modulus;
332-
333-
template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
334-
_LIBCPP_CONSTEXPR const typename linear_congruential_engine<_UIntType, __a, __c, __m>::result_type
335-
linear_congruential_engine<_UIntType, __a, __c, __m>::default_seed;
336-
337321
template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m>
338322
template <class _Sseq>
339323
void linear_congruential_engine<_UIntType, __a, __c, __m>::__seed(_Sseq& __q, integral_constant<unsigned, 1>) {

‎libcxx/include/__random/mersenne_twister_engine.h

+14-337
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,22 @@ class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine {
166166
static_assert(__f <= _Max, "mersenne_twister_engine invalid parameters");
167167

168168
// engine characteristics
169-
static _LIBCPP_CONSTEXPR const size_t word_size = __w;
170-
static _LIBCPP_CONSTEXPR const size_t state_size = __n;
171-
static _LIBCPP_CONSTEXPR const size_t shift_size = __m;
172-
static _LIBCPP_CONSTEXPR const size_t mask_bits = __r;
173-
static _LIBCPP_CONSTEXPR const result_type xor_mask = __a;
174-
static _LIBCPP_CONSTEXPR const size_t tempering_u = __u;
175-
static _LIBCPP_CONSTEXPR const result_type tempering_d = __d;
176-
static _LIBCPP_CONSTEXPR const size_t tempering_s = __s;
177-
static _LIBCPP_CONSTEXPR const result_type tempering_b = __b;
178-
static _LIBCPP_CONSTEXPR const size_t tempering_t = __t;
179-
static _LIBCPP_CONSTEXPR const result_type tempering_c = __c;
180-
static _LIBCPP_CONSTEXPR const size_t tempering_l = __l;
181-
static _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
169+
static inline _LIBCPP_CONSTEXPR const size_t word_size = __w;
170+
static inline _LIBCPP_CONSTEXPR const size_t state_size = __n;
171+
static inline _LIBCPP_CONSTEXPR const size_t shift_size = __m;
172+
static inline _LIBCPP_CONSTEXPR const size_t mask_bits = __r;
173+
static inline _LIBCPP_CONSTEXPR const result_type xor_mask = __a;
174+
static inline _LIBCPP_CONSTEXPR const size_t tempering_u = __u;
175+
static inline _LIBCPP_CONSTEXPR const result_type tempering_d = __d;
176+
static inline _LIBCPP_CONSTEXPR const size_t tempering_s = __s;
177+
static inline _LIBCPP_CONSTEXPR const result_type tempering_b = __b;
178+
static inline _LIBCPP_CONSTEXPR const size_t tempering_t = __t;
179+
static inline _LIBCPP_CONSTEXPR const result_type tempering_c = __c;
180+
static inline _LIBCPP_CONSTEXPR const size_t tempering_l = __l;
181+
static inline _LIBCPP_CONSTEXPR const result_type initialization_multiplier = __f;
182182
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
183183
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
184-
static _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
184+
static inline _LIBCPP_CONSTEXPR const result_type default_seed = 5489u;
185185

186186
// constructors and seeding functions
187187
#ifndef _LIBCPP_CXX03_LANG
@@ -310,329 +310,6 @@ class _LIBCPP_TEMPLATE_VIS mersenne_twister_engine {
310310
}
311311
};
312312

313-
template <class _UIntType,
314-
size_t __w,
315-
size_t __n,
316-
size_t __m,
317-
size_t __r,
318-
_UIntType __a,
319-
size_t __u,
320-
_UIntType __d,
321-
size_t __s,
322-
_UIntType __b,
323-
size_t __t,
324-
_UIntType __c,
325-
size_t __l,
326-
_UIntType __f>
327-
_LIBCPP_CONSTEXPR const size_t
328-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::word_size;
329-
330-
template <class _UIntType,
331-
size_t __w,
332-
size_t __n,
333-
size_t __m,
334-
size_t __r,
335-
_UIntType __a,
336-
size_t __u,
337-
_UIntType __d,
338-
size_t __s,
339-
_UIntType __b,
340-
size_t __t,
341-
_UIntType __c,
342-
size_t __l,
343-
_UIntType __f>
344-
_LIBCPP_CONSTEXPR const size_t
345-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::state_size;
346-
347-
template <class _UIntType,
348-
size_t __w,
349-
size_t __n,
350-
size_t __m,
351-
size_t __r,
352-
_UIntType __a,
353-
size_t __u,
354-
_UIntType __d,
355-
size_t __s,
356-
_UIntType __b,
357-
size_t __t,
358-
_UIntType __c,
359-
size_t __l,
360-
_UIntType __f>
361-
_LIBCPP_CONSTEXPR const size_t
362-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::shift_size;
363-
364-
template <class _UIntType,
365-
size_t __w,
366-
size_t __n,
367-
size_t __m,
368-
size_t __r,
369-
_UIntType __a,
370-
size_t __u,
371-
_UIntType __d,
372-
size_t __s,
373-
_UIntType __b,
374-
size_t __t,
375-
_UIntType __c,
376-
size_t __l,
377-
_UIntType __f>
378-
_LIBCPP_CONSTEXPR const size_t
379-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::mask_bits;
380-
381-
template <class _UIntType,
382-
size_t __w,
383-
size_t __n,
384-
size_t __m,
385-
size_t __r,
386-
_UIntType __a,
387-
size_t __u,
388-
_UIntType __d,
389-
size_t __s,
390-
_UIntType __b,
391-
size_t __t,
392-
_UIntType __c,
393-
size_t __l,
394-
_UIntType __f>
395-
_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
396-
_UIntType,
397-
__w,
398-
__n,
399-
__m,
400-
__r,
401-
__a,
402-
__u,
403-
__d,
404-
__s,
405-
__b,
406-
__t,
407-
__c,
408-
__l,
409-
__f>::result_type
410-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::xor_mask;
411-
412-
template <class _UIntType,
413-
size_t __w,
414-
size_t __n,
415-
size_t __m,
416-
size_t __r,
417-
_UIntType __a,
418-
size_t __u,
419-
_UIntType __d,
420-
size_t __s,
421-
_UIntType __b,
422-
size_t __t,
423-
_UIntType __c,
424-
size_t __l,
425-
_UIntType __f>
426-
_LIBCPP_CONSTEXPR const size_t
427-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_u;
428-
429-
template <class _UIntType,
430-
size_t __w,
431-
size_t __n,
432-
size_t __m,
433-
size_t __r,
434-
_UIntType __a,
435-
size_t __u,
436-
_UIntType __d,
437-
size_t __s,
438-
_UIntType __b,
439-
size_t __t,
440-
_UIntType __c,
441-
size_t __l,
442-
_UIntType __f>
443-
_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
444-
_UIntType,
445-
__w,
446-
__n,
447-
__m,
448-
__r,
449-
__a,
450-
__u,
451-
__d,
452-
__s,
453-
__b,
454-
__t,
455-
__c,
456-
__l,
457-
__f>::result_type
458-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_d;
459-
460-
template <class _UIntType,
461-
size_t __w,
462-
size_t __n,
463-
size_t __m,
464-
size_t __r,
465-
_UIntType __a,
466-
size_t __u,
467-
_UIntType __d,
468-
size_t __s,
469-
_UIntType __b,
470-
size_t __t,
471-
_UIntType __c,
472-
size_t __l,
473-
_UIntType __f>
474-
_LIBCPP_CONSTEXPR const size_t
475-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_s;
476-
477-
template <class _UIntType,
478-
size_t __w,
479-
size_t __n,
480-
size_t __m,
481-
size_t __r,
482-
_UIntType __a,
483-
size_t __u,
484-
_UIntType __d,
485-
size_t __s,
486-
_UIntType __b,
487-
size_t __t,
488-
_UIntType __c,
489-
size_t __l,
490-
_UIntType __f>
491-
_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
492-
_UIntType,
493-
__w,
494-
__n,
495-
__m,
496-
__r,
497-
__a,
498-
__u,
499-
__d,
500-
__s,
501-
__b,
502-
__t,
503-
__c,
504-
__l,
505-
__f>::result_type
506-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_b;
507-
508-
template <class _UIntType,
509-
size_t __w,
510-
size_t __n,
511-
size_t __m,
512-
size_t __r,
513-
_UIntType __a,
514-
size_t __u,
515-
_UIntType __d,
516-
size_t __s,
517-
_UIntType __b,
518-
size_t __t,
519-
_UIntType __c,
520-
size_t __l,
521-
_UIntType __f>
522-
_LIBCPP_CONSTEXPR const size_t
523-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_t;
524-
525-
template <class _UIntType,
526-
size_t __w,
527-
size_t __n,
528-
size_t __m,
529-
size_t __r,
530-
_UIntType __a,
531-
size_t __u,
532-
_UIntType __d,
533-
size_t __s,
534-
_UIntType __b,
535-
size_t __t,
536-
_UIntType __c,
537-
size_t __l,
538-
_UIntType __f>
539-
_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
540-
_UIntType,
541-
__w,
542-
__n,
543-
__m,
544-
__r,
545-
__a,
546-
__u,
547-
__d,
548-
__s,
549-
__b,
550-
__t,
551-
__c,
552-
__l,
553-
__f>::result_type
554-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_c;
555-
556-
template <class _UIntType,
557-
size_t __w,
558-
size_t __n,
559-
size_t __m,
560-
size_t __r,
561-
_UIntType __a,
562-
size_t __u,
563-
_UIntType __d,
564-
size_t __s,
565-
_UIntType __b,
566-
size_t __t,
567-
_UIntType __c,
568-
size_t __l,
569-
_UIntType __f>
570-
_LIBCPP_CONSTEXPR const size_t
571-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::tempering_l;
572-
573-
template <class _UIntType,
574-
size_t __w,
575-
size_t __n,
576-
size_t __m,
577-
size_t __r,
578-
_UIntType __a,
579-
size_t __u,
580-
_UIntType __d,
581-
size_t __s,
582-
_UIntType __b,
583-
size_t __t,
584-
_UIntType __c,
585-
size_t __l,
586-
_UIntType __f>
587-
_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
588-
_UIntType,
589-
__w,
590-
__n,
591-
__m,
592-
__r,
593-
__a,
594-
__u,
595-
__d,
596-
__s,
597-
__b,
598-
__t,
599-
__c,
600-
__l,
601-
__f>::result_type
602-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::
603-
initialization_multiplier;
604-
605-
template <class _UIntType,
606-
size_t __w,
607-
size_t __n,
608-
size_t __m,
609-
size_t __r,
610-
_UIntType __a,
611-
size_t __u,
612-
_UIntType __d,
613-
size_t __s,
614-
_UIntType __b,
615-
size_t __t,
616-
_UIntType __c,
617-
size_t __l,
618-
_UIntType __f>
619-
_LIBCPP_CONSTEXPR const typename mersenne_twister_engine<
620-
_UIntType,
621-
__w,
622-
__n,
623-
__m,
624-
__r,
625-
__a,
626-
__u,
627-
__d,
628-
__s,
629-
__b,
630-
__t,
631-
__c,
632-
__l,
633-
__f>::result_type
634-
mersenne_twister_engine<_UIntType, __w, __n, __m, __r, __a, __u, __d, __s, __b, __t, __c, __l, __f>::default_seed;
635-
636313
template <class _UIntType,
637314
size_t __w,
638315
size_t __n,

‎libcxx/include/__random/shuffle_order_engine.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _LIBCPP_TEMPLATE_VIS shuffle_order_engine {
6666

6767
public:
6868
// engine characteristics
69-
static _LIBCPP_CONSTEXPR const size_t table_size = __k;
69+
static inline _LIBCPP_CONSTEXPR const size_t table_size = __k;
7070

7171
#ifdef _LIBCPP_CXX03_LANG
7272
static const result_type _Min = _Engine::_Min;
@@ -173,9 +173,6 @@ class _LIBCPP_TEMPLATE_VIS shuffle_order_engine {
173173
}
174174
};
175175

176-
template <class _Engine, size_t __k>
177-
_LIBCPP_CONSTEXPR const size_t shuffle_order_engine<_Engine, __k>::table_size;
178-
179176
template <class _Eng, size_t _Kp>
180177
_LIBCPP_HIDE_FROM_ABI bool
181178
operator==(const shuffle_order_engine<_Eng, _Kp>& __x, const shuffle_order_engine<_Eng, _Kp>& __y) {

‎libcxx/include/__random/subtract_with_carry_engine.h

+4-17
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine {
7272
static_assert(_Min < _Max, "subtract_with_carry_engine invalid parameters");
7373

7474
// engine characteristics
75-
static _LIBCPP_CONSTEXPR const size_t word_size = __w;
76-
static _LIBCPP_CONSTEXPR const size_t short_lag = __s;
77-
static _LIBCPP_CONSTEXPR const size_t long_lag = __r;
75+
static inline _LIBCPP_CONSTEXPR const size_t word_size = __w;
76+
static inline _LIBCPP_CONSTEXPR const size_t short_lag = __s;
77+
static inline _LIBCPP_CONSTEXPR const size_t long_lag = __r;
7878
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type min() { return _Min; }
7979
_LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR result_type max() { return _Max; }
80-
static _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
80+
static inline _LIBCPP_CONSTEXPR const result_type default_seed = 19780503u;
8181

8282
// constructors and seeding functions
8383
#ifndef _LIBCPP_CXX03_LANG
@@ -130,19 +130,6 @@ class _LIBCPP_TEMPLATE_VIS subtract_with_carry_engine {
130130
_LIBCPP_HIDE_FROM_ABI void __seed(_Sseq& __q, integral_constant<unsigned, 2>);
131131
};
132132

133-
template <class _UIntType, size_t __w, size_t __s, size_t __r>
134-
_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::word_size;
135-
136-
template <class _UIntType, size_t __w, size_t __s, size_t __r>
137-
_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::short_lag;
138-
139-
template <class _UIntType, size_t __w, size_t __s, size_t __r>
140-
_LIBCPP_CONSTEXPR const size_t subtract_with_carry_engine<_UIntType, __w, __s, __r>::long_lag;
141-
142-
template <class _UIntType, size_t __w, size_t __s, size_t __r>
143-
_LIBCPP_CONSTEXPR const typename subtract_with_carry_engine<_UIntType, __w, __s, __r>::result_type
144-
subtract_with_carry_engine<_UIntType, __w, __s, __r>::default_seed;
145-
146133
template <class _UIntType, size_t __w, size_t __s, size_t __r>
147134
void subtract_with_carry_engine<_UIntType, __w, __s, __r>::seed(result_type __sd, integral_constant<unsigned, 1>) {
148135
linear_congruential_engine<result_type, 40014u, 0u, 2147483563u> __e(__sd == 0u ? default_seed : __sd);

‎libcxx/include/__type_traits/integral_constant.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1919

2020
template <class _Tp, _Tp __v>
2121
struct _LIBCPP_TEMPLATE_VIS integral_constant {
22-
static _LIBCPP_CONSTEXPR const _Tp value = __v;
22+
static inline _LIBCPP_CONSTEXPR const _Tp value = __v;
2323
typedef _Tp value_type;
2424
typedef integral_constant type;
2525
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR operator value_type() const _NOEXCEPT { return value; }
@@ -28,9 +28,6 @@ struct _LIBCPP_TEMPLATE_VIS integral_constant {
2828
#endif
2929
};
3030

31-
template <class _Tp, _Tp __v>
32-
_LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value;
33-
3431
typedef integral_constant<bool, true> true_type;
3532
typedef integral_constant<bool, false> false_type;
3633

‎libcxx/include/any

-2
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,6 @@ template <class _Tp>
166166
struct _LIBCPP_TEMPLATE_VIS __unique_typeinfo {
167167
static constexpr int __id = 0;
168168
};
169-
template <class _Tp>
170-
constexpr int __unique_typeinfo<_Tp>::__id;
171169

172170
template <class _Tp>
173171
inline _LIBCPP_HIDE_FROM_ABI constexpr const void* __get_fallback_typeid() {

‎libcxx/include/limits

+23-70
Original file line numberDiff line numberDiff line change
@@ -464,36 +464,36 @@ class _LIBCPP_TEMPLATE_VIS numeric_limits : private __libcpp_numeric_limits<_Tp>
464464
typedef typename __base::type type;
465465

466466
public:
467-
static _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
467+
static inline _LIBCPP_CONSTEXPR const bool is_specialized = __base::is_specialized;
468468
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type min() _NOEXCEPT { return __base::min(); }
469469
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type max() _NOEXCEPT { return __base::max(); }
470470
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type lowest() _NOEXCEPT { return __base::lowest(); }
471471

472-
static _LIBCPP_CONSTEXPR const int digits = __base::digits;
473-
static _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
474-
static _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
475-
static _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
476-
static _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
477-
static _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
478-
static _LIBCPP_CONSTEXPR const int radix = __base::radix;
472+
static inline _LIBCPP_CONSTEXPR const int digits = __base::digits;
473+
static inline _LIBCPP_CONSTEXPR const int digits10 = __base::digits10;
474+
static inline _LIBCPP_CONSTEXPR const int max_digits10 = __base::max_digits10;
475+
static inline _LIBCPP_CONSTEXPR const bool is_signed = __base::is_signed;
476+
static inline _LIBCPP_CONSTEXPR const bool is_integer = __base::is_integer;
477+
static inline _LIBCPP_CONSTEXPR const bool is_exact = __base::is_exact;
478+
static inline _LIBCPP_CONSTEXPR const int radix = __base::radix;
479479
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type epsilon() _NOEXCEPT {
480480
return __base::epsilon();
481481
}
482482
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type round_error() _NOEXCEPT {
483483
return __base::round_error();
484484
}
485485

486-
static _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
487-
static _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
488-
static _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
489-
static _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
486+
static inline _LIBCPP_CONSTEXPR const int min_exponent = __base::min_exponent;
487+
static inline _LIBCPP_CONSTEXPR const int min_exponent10 = __base::min_exponent10;
488+
static inline _LIBCPP_CONSTEXPR const int max_exponent = __base::max_exponent;
489+
static inline _LIBCPP_CONSTEXPR const int max_exponent10 = __base::max_exponent10;
490490

491-
static _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
492-
static _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
493-
static _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
491+
static inline _LIBCPP_CONSTEXPR const bool has_infinity = __base::has_infinity;
492+
static inline _LIBCPP_CONSTEXPR const bool has_quiet_NaN = __base::has_quiet_NaN;
493+
static inline _LIBCPP_CONSTEXPR const bool has_signaling_NaN = __base::has_signaling_NaN;
494494
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
495-
static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
496-
static _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
495+
static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const float_denorm_style has_denorm = __base::has_denorm;
496+
static inline _LIBCPP_DEPRECATED_IN_CXX23 _LIBCPP_CONSTEXPR const bool has_denorm_loss = __base::has_denorm_loss;
497497
_LIBCPP_SUPPRESS_DEPRECATED_POP
498498
[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI static _LIBCPP_CONSTEXPR type infinity() _NOEXCEPT {
499499
return __base::infinity();
@@ -508,62 +508,15 @@ public:
508508
return __base::denorm_min();
509509
}
510510

511-
static _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
512-
static _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
513-
static _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
511+
static inline _LIBCPP_CONSTEXPR const bool is_iec559 = __base::is_iec559;
512+
static inline _LIBCPP_CONSTEXPR const bool is_bounded = __base::is_bounded;
513+
static inline _LIBCPP_CONSTEXPR const bool is_modulo = __base::is_modulo;
514514

515-
static _LIBCPP_CONSTEXPR const bool traps = __base::traps;
516-
static _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
517-
static _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
515+
static inline _LIBCPP_CONSTEXPR const bool traps = __base::traps;
516+
static inline _LIBCPP_CONSTEXPR const bool tinyness_before = __base::tinyness_before;
517+
static inline _LIBCPP_CONSTEXPR const float_round_style round_style = __base::round_style;
518518
};
519519

520-
template <class _Tp>
521-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_specialized;
522-
template <class _Tp>
523-
_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits;
524-
template <class _Tp>
525-
_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::digits10;
526-
template <class _Tp>
527-
_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_digits10;
528-
template <class _Tp>
529-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_signed;
530-
template <class _Tp>
531-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_integer;
532-
template <class _Tp>
533-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_exact;
534-
template <class _Tp>
535-
_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::radix;
536-
template <class _Tp>
537-
_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent;
538-
template <class _Tp>
539-
_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::min_exponent10;
540-
template <class _Tp>
541-
_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent;
542-
template <class _Tp>
543-
_LIBCPP_CONSTEXPR const int numeric_limits<_Tp>::max_exponent10;
544-
template <class _Tp>
545-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_infinity;
546-
template <class _Tp>
547-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_quiet_NaN;
548-
template <class _Tp>
549-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_signaling_NaN;
550-
template <class _Tp>
551-
_LIBCPP_CONSTEXPR const float_denorm_style numeric_limits<_Tp>::has_denorm;
552-
template <class _Tp>
553-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::has_denorm_loss;
554-
template <class _Tp>
555-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_iec559;
556-
template <class _Tp>
557-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_bounded;
558-
template <class _Tp>
559-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::is_modulo;
560-
template <class _Tp>
561-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::traps;
562-
template <class _Tp>
563-
_LIBCPP_CONSTEXPR const bool numeric_limits<_Tp>::tinyness_before;
564-
template <class _Tp>
565-
_LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style;
566-
567520
template <class _Tp>
568521
class _LIBCPP_TEMPLATE_VIS numeric_limits<const _Tp> : public numeric_limits<_Tp> {};
569522

‎libcxx/include/ratio

+2-8
Original file line numberDiff line numberDiff line change
@@ -236,18 +236,12 @@ class _LIBCPP_TEMPLATE_VIS ratio {
236236
static _LIBCPP_CONSTEXPR const intmax_t __gcd = __static_gcd<__na, __da>;
237237

238238
public:
239-
static _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
240-
static _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
239+
static inline _LIBCPP_CONSTEXPR const intmax_t num = __s * __na / __gcd;
240+
static inline _LIBCPP_CONSTEXPR const intmax_t den = __da / __gcd;
241241

242242
typedef ratio<num, den> type;
243243
};
244244

245-
template <intmax_t _Num, intmax_t _Den>
246-
_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::num;
247-
248-
template <intmax_t _Num, intmax_t _Den>
249-
_LIBCPP_CONSTEXPR const intmax_t ratio<_Num, _Den>::den;
250-
251245
template <class _Tp>
252246
inline const bool __is_ratio_v = false;
253247

‎libcxx/src/chrono.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ static system_clock::time_point __libcpp_system_clock_now() {
134134

135135
#endif
136136

137+
_LIBCPP_DIAGNOSTIC_PUSH
138+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
137139
const bool system_clock::is_steady;
140+
_LIBCPP_DIAGNOSTIC_POP
138141

139142
system_clock::time_point system_clock::now() noexcept { return __libcpp_system_clock_now(); }
140143

@@ -226,7 +229,10 @@ static steady_clock::time_point __libcpp_steady_clock_now() {
226229
# error "Monotonic clock not implemented on this platform"
227230
# endif
228231

232+
_LIBCPP_DIAGNOSTIC_PUSH
233+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
229234
const bool steady_clock::is_steady;
235+
_LIBCPP_DIAGNOSTIC_POP
230236

231237
steady_clock::time_point steady_clock::now() noexcept { return __libcpp_steady_clock_now(); }
232238

‎libcxx/src/filesystem/filesystem_clock.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636

3737
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
3838

39+
_LIBCPP_DIAGNOSTIC_PUSH
40+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
3941
const bool _FilesystemClock::is_steady;
42+
_LIBCPP_DIAGNOSTIC_POP
4043

4144
_FilesystemClock::time_point _FilesystemClock::now() noexcept {
4245
typedef chrono::duration<rep> __secs;

‎libcxx/src/filesystem/path.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ using parser::string_view_t;
2424
// path definitions
2525
///////////////////////////////////////////////////////////////////////////////
2626

27+
_LIBCPP_DIAGNOSTIC_PUSH
28+
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated")
2729
constexpr path::value_type path::preferred_separator;
30+
_LIBCPP_DIAGNOSTIC_POP
2831

2932
path& path::replace_extension(path const& replacement) {
3033
path p = extension();

‎libcxxabi/src/cxa_demangle.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,6 @@
2828

2929
using namespace itanium_demangle;
3030

31-
constexpr const char *itanium_demangle::FloatData<float>::spec;
32-
constexpr const char *itanium_demangle::FloatData<double>::spec;
33-
constexpr const char *itanium_demangle::FloatData<long double>::spec;
34-
3531
// <discriminator> := _ <non-negative number> # when number < 10
3632
// := __ <non-negative number> _ # when number >= 10
3733
// extension := decimal-digit+ # at the end of string

‎runtimes/cmake/Modules/WarningFlags.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ function(cxx_add_warning_flags target enable_werror enable_pedantic)
2424
-Wunused-template
2525
-Wformat-nonliteral
2626
-Wzero-length-array
27+
-Wdeprecated-redundant-constexpr-static-def
2728
)
2829

2930
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")

0 commit comments

Comments
 (0)
Please sign in to comment.