1 // Copyright (C) 2019-2021 Free Software Foundation, Inc. 2 // 3 // This file is part of the GNU ISO C++ Library. This library is free 4 // software; you can redistribute it and/or modify it under the 5 // terms of the GNU General Public License as published by the 6 // Free Software Foundation; either version 3, or (at your option) 7 // any later version. 8 9 // This library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 14 // You should have received a copy of the GNU General Public License along 15 // with this library; see the file COPYING3. If not see 16 // <http://www.gnu.org/licenses/>. 17 18 // { dg-do compile { target c++17 } } 19 20 #include <charconv> 21 22 // C++17 23.2.1 [utility.syn] 23 // chars_format is a bitmask type with elements scientific, fixed and hex 24 25 using F = std::chars_format; 26 const F none = F{}; 27 const F all = ~none; 28 static_assert(std::is_enum_v<F>); 29 static_assert((F::scientific & F::fixed) == none); 30 static_assert((F::scientific & F::hex) == none); 31 static_assert((F::fixed & F::hex) == none); 32 static_assert(F::general == (F::fixed | F::scientific)); 33 static_assert(F::general == (F::fixed ^ F::scientific)); 34 35 // sanity check operators 36 static_assert((F::scientific & F::scientific) == F::scientific); 37 static_assert((F::fixed & F::fixed) == F::fixed); 38 static_assert((F::hex & F::hex) == F::hex); 39 static_assert((F::general & F::general) == F::general); 40 static_assert((F::scientific | F::scientific) == F::scientific); 41 static_assert((F::fixed | F::fixed) == F::fixed); 42 static_assert((F::hex | F::hex) == F::hex); 43 static_assert((F::general | F::general) == F::general); 44 static_assert((F::scientific ^ F::scientific) == none); 45 static_assert((F::fixed ^ F::fixed) == none); 46 static_assert((F::hex ^ F::hex) == none); 47 static_assert((F::general ^ F::general) == none); 48 static_assert((F::fixed & all) == F::fixed); 49 static_assert((F::hex & all) == F::hex); 50 static_assert((F::general & all) == F::general); 51 static_assert(~all == none); 52