Home | History | Annotate | Download | only in any.modifiers
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // UNSUPPORTED: c++98, c++03, c++11, c++14
     11 
     12 // XFAIL: availability=macosx10.13
     13 // XFAIL: availability=macosx10.12
     14 // XFAIL: availability=macosx10.11
     15 // XFAIL: availability=macosx10.10
     16 // XFAIL: availability=macosx10.9
     17 // XFAIL: availability=macosx10.8
     18 // XFAIL: availability=macosx10.7
     19 
     20 // <any>
     21 
     22 // any::reset() noexcept
     23 
     24 #include <any>
     25 #include <cassert>
     26 
     27 #include "any_helpers.h"
     28 
     29 int main()
     30 {
     31     using std::any;
     32     using std::any_cast;
     33     // empty
     34     {
     35         any a;
     36 
     37         // noexcept check
     38         static_assert(
     39             noexcept(a.reset())
     40           , "any.reset() must be noexcept"
     41           );
     42 
     43         assertEmpty(a);
     44 
     45         a.reset();
     46 
     47         assertEmpty(a);
     48     }
     49     // small object
     50     {
     51         any a((small(1)));
     52         assert(small::count == 1);
     53         assertContains<small>(a, 1);
     54 
     55         a.reset();
     56 
     57         assertEmpty<small>(a);
     58         assert(small::count == 0);
     59     }
     60     // large object
     61     {
     62         any a(large(1));
     63         assert(large::count == 1);
     64         assertContains<large>(a, 1);
     65 
     66         a.reset();
     67 
     68         assertEmpty<large>(a);
     69         assert(large::count == 0);
     70     }
     71 }
     72