Lines Matching refs:Type

71 template <class Type, class ConstT = Type>
76 any_cast<Type>(a);
94 any_cast<Type>(static_cast<any&&>(a));
113 template <class Type>
115 assert(Type::count == 0);
116 Type::reset();
118 any a((Type(42)));
120 assert(Type::count == 1);
121 assert(Type::copied == 0);
122 assert(Type::moved == 1);
125 // NOTE: Type cannot be an int.
128 checkThrows<Type*, Type const*>(a);
129 checkThrows<Type const*>(a);
133 Type& v = any_cast<Type&>(a);
136 Type const &cv = any_cast<Type const&>(a);
141 Type const& v = any_cast<Type const&>(ca);
144 Type const &cv = any_cast<Type const&>(ca);
149 Type& v = any_cast<Type&>(std::move(a));
152 Type const &cv = any_cast<Type const&>(std::move(a));
157 Type const& v = any_cast<Type const&>(std::move(ca));
160 Type const &cv = any_cast<Type const&>(std::move(ca));
165 assertContains<Type>(a, 42);
168 assert(Type::count == 1);
169 assert(Type::copied == 0);
170 assert(Type::moved == 1);
172 assert(Type::count == 0);
175 template <class Type>
177 assert(Type::count == 0);
178 Type::reset();
180 any a((Type(42)));
181 assert(Type::count == 1);
182 assert(Type::copied == 0);
183 assert(Type::moved == 1);
186 // NOTE: Type cannot be an int.
189 checkThrows<Type*, Type const*>(a);
190 checkThrows<Type const*>(a);
192 Type::reset(); // NOTE: reset does not modify Type::count
193 // Check getting Type by value from a non-const lvalue any.
196 Type t = any_cast<Type>(a);
198 assert(Type::count == 2);
199 assert(Type::copied == 1);
200 assert(Type::const_copied == 0);
201 assert(Type::non_const_copied == 1);
202 assert(Type::moved == 0);
205 assert(Type::count == 1);
206 Type::reset();
207 // Check getting const Type by value from a non-const lvalue any.
210 Type t = any_cast<Type const>(a);
212 assert(Type::count == 2);
213 assert(Type::copied == 1);
214 assert(Type::const_copied == 1);
215 assert(Type::non_const_copied == 0);
216 assert(Type::moved == 0);
219 assert(Type::count == 1);
220 Type::reset();
221 // Check getting Type by value from a non-const lvalue any.
224 Type t = any_cast<Type>(static_cast<any const&>(a));
226 assert(Type::count == 2);
227 assert(Type::copied == 1);
228 assert(Type::const_copied == 1);
229 assert(Type::non_const_copied == 0);
230 assert(Type::moved == 0);
233 assert(Type::count == 1);
234 Type::reset();
235 // Check getting Type by value from a non-const rvalue any.
238 Type t = any_cast<Type>(static_cast<any &&>(a));
240 assert(Type::count == 2);
241 assert(Type::copied == 1);
242 assert(Type::const_copied == 0);
243 assert(Type::non_const_copied == 1);
244 assert(Type::moved == 0);
247 assert(Type::count == 1);
248 Type::reset();
249 // Check getting const Type by value from a non-const rvalue any.
252 Type t = any_cast<Type const>(static_cast<any &&>(a));
254 assert(Type::count == 2);
255 assert(Type::copied == 1);
256 assert(Type::const_copied == 1);
257 assert(Type::non_const_copied == 0);
258 assert(Type::moved == 0);
261 assert(Type::count == 1);
262 Type::reset();
263 // Check getting Type by value from a const rvalue any.
266 Type t = any_cast<Type>(static_cast<any const&&>(a));
268 assert(Type::count == 2);
269 assert(Type::copied == 1);
270 assert(Type::const_copied == 1);
271 assert(Type::non_const_copied == 0);
272 assert(Type::moved == 0);
275 // Ensure we still only have 1 Type object alive.
276 assert(Type::count == 1);
279 assertContains<Type>(a, 42);
281 assert(Type::count == 0);