@@ -34,13 +34,13 @@ namespace std {
34
34
T* ptr;
35
35
36
36
public:
37
- reference_wrapper (T& ref) : ptr(&ref) {}
37
+ constexpr reference_wrapper (T& ref) : ptr(&ref) {}
38
38
39
- T& get () { return *ptr; }
39
+ constexpr T& get () { return *ptr; }
40
40
};
41
41
42
42
template <class T >
43
- reference_wrapper<T> ref (T& v) {
43
+ constexpr reference_wrapper<T> ref (T& v) {
44
44
return reference_wrapper<T>(v);
45
45
}
46
46
} // namespace std
@@ -190,3 +190,42 @@ void call3() {
190
190
func (d, &DependentTest::func);
191
191
func (d, &DependentTest::bad_func); // expected-note {{requested here}}
192
192
}
193
+
194
+ constexpr int constexpr_func () {
195
+ return 42 ;
196
+ }
197
+
198
+ struct ConstexprTestStruct {
199
+ int i;
200
+ constexpr int func () {
201
+ return 55 ;
202
+ }
203
+ };
204
+
205
+ // Make sure that constant evaluation works
206
+ static_assert ([]() {
207
+
208
+ ConstexprTestStruct s;
209
+ if (__builtin_invoke (&ConstexprTestStruct::func, s) != 55 ) // [func.requires]/p1.1
210
+ return false ;
211
+ if (__builtin_invoke (&ConstexprTestStruct::func, std::ref (s)) != 55 ) // [func.requires]/p1.2
212
+ return false ;
213
+ if (__builtin_invoke (&ConstexprTestStruct::func, &s) != 55 ) // [func.requires]/p1.3
214
+ return false ;
215
+
216
+ s.i = 22 ;
217
+ if (__builtin_invoke (&ConstexprTestStruct::i, s) != 22 ) // [func.requires]/p1.4
218
+ return false ;
219
+ if (__builtin_invoke (&ConstexprTestStruct::i, std::ref (s)) != 22 ) // [func.requires]/p1.5
220
+ return false ;
221
+ if (__builtin_invoke (&ConstexprTestStruct::i, &s) != 22 ) // [func.requires]/p1.6
222
+ return false ;
223
+
224
+ // [func.requires]/p1.7
225
+ if (__builtin_invoke (constexpr_func) != 42 )
226
+ return false ;
227
+ if (__builtin_invoke ([] { return 34 ; }) != 34 )
228
+ return false ;
229
+
230
+ return true ;
231
+ }());
0 commit comments