@@ -3143,6 +3143,10 @@ void reference_binds_to_temporary_checks() {
3143
3143
static_assert (!(__reference_binds_to_temporary (int , long )));
3144
3144
3145
3145
static_assert ((__reference_binds_to_temporary (const int &, long )));
3146
+
3147
+ // Test that function references are never considered bound to temporaries.
3148
+ static_assert (!__reference_binds_to_temporary (void (&)(), void ()));
3149
+ static_assert (!__reference_binds_to_temporary (void (&&)(), void ()));
3146
3150
}
3147
3151
3148
3152
@@ -3156,6 +3160,14 @@ struct ExplicitConversionRef {
3156
3160
explicit operator int &();
3157
3161
};
3158
3162
3163
+ struct NonMovable {
3164
+ NonMovable (NonMovable&&) = delete ;
3165
+ };
3166
+
3167
+ struct ConvertsFromNonMovable {
3168
+ ConvertsFromNonMovable (NonMovable);
3169
+ };
3170
+
3159
3171
void reference_constructs_from_temporary_checks () {
3160
3172
static_assert (!__reference_constructs_from_temporary (int &, int &));
3161
3173
static_assert (!__reference_constructs_from_temporary (int &, int &&));
@@ -3193,6 +3205,16 @@ void reference_constructs_from_temporary_checks() {
3193
3205
3194
3206
static_assert (__reference_constructs_from_temporary (const int &, long ));
3195
3207
3208
+ // Test that function references are never considered bound to temporaries.
3209
+ static_assert (!__reference_constructs_from_temporary (void (&&)(), void ()));
3210
+ static_assert (!__reference_constructs_from_temporary (void (&)(), void ()));
3211
+
3212
+ // LWG3819: reference_meows_from_temporary should not use is_meowible
3213
+ static_assert (__reference_constructs_from_temporary (ConvertsFromNonMovable&&, NonMovable) == __cplusplus >= 201703L );
3214
+ // For scalar types, cv-qualifications are dropped first for prvalues.
3215
+ static_assert (__reference_constructs_from_temporary (int &&, const int ));
3216
+ static_assert (__reference_constructs_from_temporary (int &&, volatile int ));
3217
+
3196
3218
// Additional checks
3197
3219
static_assert (__reference_constructs_from_temporary (POD const &, Derives));
3198
3220
static_assert (__reference_constructs_from_temporary (int &&, int ));
@@ -3250,6 +3272,16 @@ void reference_converts_from_temporary_checks() {
3250
3272
3251
3273
static_assert (__reference_converts_from_temporary (const int &, long ));
3252
3274
3275
+ // Test that function references are never considered bound to temporaries.
3276
+ static_assert (!__reference_converts_from_temporary (void (&)(), void ()));
3277
+ static_assert (!__reference_converts_from_temporary (void (&&)(), void ()));
3278
+
3279
+ // LWG3819: reference_meows_from_temporary should not use is_meowible
3280
+ static_assert (__reference_converts_from_temporary (ConvertsFromNonMovable&&, NonMovable) == __cplusplus >= 201703L );
3281
+ // For scalar types, cv-qualifications are dropped first for prvalues.
3282
+ static_assert (__reference_converts_from_temporary (int &&, const int ));
3283
+ static_assert (__reference_converts_from_temporary (int &&, volatile int ));
3284
+
3253
3285
// Additional checks
3254
3286
static_assert (__reference_converts_from_temporary (POD const &, Derives));
3255
3287
static_assert (__reference_converts_from_temporary (int &&, int ));
0 commit comments