Lines Matching refs:Type

71 template <class Type, class ConstT = Type>
76 any_cast<Type>(a);
95 std::is_lvalue_reference<Type>::value,
96 typename std::remove_reference<Type>::type&&,
97 Type
118 template <class Type>
120 assert(Type::count == 0);
121 Type::reset();
123 any a((Type(42)));
125 assert(Type::count == 1);
126 assert(Type::copied == 0);
127 assert(Type::moved == 1);
130 // NOTE: Type cannot be an int.
133 checkThrows<Type*, Type const*>(a);
134 checkThrows<Type const*>(a);
138 Type& v = any_cast<Type&>(a);
141 Type const &cv = any_cast<Type const&>(a);
146 Type const& v = any_cast<Type const&>(ca);
149 Type const &cv = any_cast<Type const&>(ca);
154 Type const& v = any_cast<Type const&>(std::move(ca));
157 Type const &cv = any_cast<Type const&>(std::move(ca));
162 Type&& v = any_cast<Type&&>(std::move(a));
164 assert(any_cast<Type&>(a).value == 42);
166 Type&& cv = any_cast<Type&&>(std::move(a));
168 assert(any_cast<Type&>(a).value == 42);
172 Type const&& v = any_cast<Type const&&>(std::move(a));
174 assert(any_cast<Type&>(a).value == 42);
176 Type const&& cv = any_cast<Type const&&>(std::move(a));
178 assert(any_cast<Type&>(a).value == 42);
181 assertContains<Type>(a, 42);
184 assert(Type::count == 1);
185 assert(Type::copied == 0);
186 assert(Type::moved == 1);
188 assert(Type::count == 0);
191 template <class Type>
193 assert(Type::count == 0);
194 Type::reset();
196 any a((Type(42)));
197 assert(Type::count == 1);
198 assert(Type::copied == 0);
199 assert(Type::moved == 1);
202 // NOTE: Type cannot be an int.
205 checkThrows<Type*, Type const*>(a);
206 checkThrows<Type const*>(a);
208 Type::reset(); // NOTE: reset does not modify Type::count
209 // Check getting Type by value from a non-const lvalue any.
212 Type t = any_cast<Type>(a);
214 assert(Type::count == 2);
215 assert(Type::copied == 1);
216 assert(Type::const_copied == 0);
217 assert(Type::non_const_copied == 1);
218 assert(Type::moved == 0);
221 assert(Type::count == 1);
222 Type::reset();
223 // Check getting const Type by value from a non-const lvalue any.
226 Type t = any_cast<Type const>(a);
228 assert(Type::count == 2);
229 assert(Type::copied == 1);
230 assert(Type::const_copied == 0);
231 assert(Type::non_const_copied == 1);
232 assert(Type::moved == 0);
235 assert(Type::count == 1);
236 Type::reset();
237 // Check getting Type by value from a non-const lvalue any.
240 Type t = any_cast<Type>(static_cast<any const&>(a));
242 assert(Type::count == 2);
243 assert(Type::copied == 1);
244 assert(Type::const_copied == 1);
245 assert(Type::non_const_copied == 0);
246 assert(Type::moved == 0);
249 assert(Type::count == 1);
250 Type::reset();
251 // Check getting Type by value from a non-const rvalue any.
254 Type t = any_cast<Type>(static_cast<any &&>(a));
256 assert(Type::count == 2);
257 assert(Type::moved == 1);
258 assert(Type::copied == 0);
259 assert(Type::const_copied == 0);
260 assert(Type::non_const_copied == 0);
262 assert(any_cast<Type&>(a).value == 0);
263 any_cast<Type&>(a).value = 42; // reset the value
265 assert(Type::count == 1);
266 Type::reset();
267 // Check getting const Type by value from a non-const rvalue any.
270 Type t = any_cast<Type const>(static_cast<any &&>(a));
272 assert(Type::count == 2);
273 assert(Type::copied == 0);
274 assert(Type::const_copied == 0);
275 assert(Type::non_const_copied == 0);
276 assert(Type::moved == 1);
278 assert(any_cast<Type&>(a).value == 0);
279 any_cast<Type&>(a).value = 42; // reset the value
281 assert(Type::count == 1);
282 Type::reset();
283 // Check getting Type by value from a const rvalue any.
286 Type t = any_cast<Type>(static_cast<any const&&>(a));
288 assert(Type::count == 2);
289 assert(Type::copied == 1);
290 assert(Type::const_copied == 1);
291 assert(Type::non_const_copied == 0);
292 assert(Type::moved == 0);
294 assert(any_cast<Type&>(a).value == 42);
296 // Ensure we still only have 1 Type object alive.
297 assert(Type::count == 1);
300 assertContains<Type>(a, 42);
302 assert(Type::count == 0);