Home | History | Annotate | Download | only in any.observers
      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
     11 
     12 // <experimental/any>
     13 
     14 // any::empty() noexcept
     15 
     16 #include <experimental/any>
     17 #include <cassert>
     18 
     19 #include "experimental_any_helpers.h"
     20 
     21 int main()
     22 {
     23     using std::experimental::any;
     24     // noexcept test
     25     {
     26         any a;
     27         static_assert(noexcept(a.empty()), "any::empty() must be noexcept");
     28     }
     29     // empty
     30     {
     31         any a;
     32         assert(a.empty());
     33 
     34         a.clear();
     35         assert(a.empty());
     36 
     37         a = 42;
     38         assert(!a.empty());
     39     }
     40     // small object
     41     {
     42         small const s(1);
     43         any a(s);
     44         assert(!a.empty());
     45 
     46         a.clear();
     47         assert(a.empty());
     48 
     49         a = s;
     50         assert(!a.empty());
     51     }
     52     // large object
     53     {
     54         large const l(1);
     55         any a(l);
     56         assert(!a.empty());
     57 
     58         a.clear();
     59         assert(a.empty());
     60 
     61         a = l;
     62         assert(!a.empty());
     63     }
     64 }
     65