1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // template <class Facet> const Facet& use_facet(const locale& loc);
17 #include "test_macros.h"
22 : public std::locale::facet
24 static std::locale::id id
;
28 my_facet() : im_alive(true) {++facet_count
;}
29 ~my_facet() {im_alive
= false; --facet_count
;}
32 std::locale::id
my_facet::id
;
36 #ifndef TEST_HAS_NO_EXCEPTIONS
39 const my_facet
& f
= std::use_facet
<my_facet
>(std::locale());
40 ((void)f
); // Prevent unused warning
43 catch (std::bad_cast
&)
47 const my_facet
* fp
= 0;
49 std::locale
loc(std::locale(), new my_facet
);
50 const my_facet
& f
= std::use_facet
<my_facet
>(loc
);
54 assert(facet_count
== 1);
56 assert(facet_count
== 0);