1//===----------------------------------------------------------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8
9// <locale>
10
11// class time_put<charT, OutputIterator>
12
13// explicit time_put(size_t refs = 0);
14
15#include <locale>
16#include <cassert>
17
18#include "test_macros.h"
19
20typedef std::time_put<char, char*> F;
21
22class my_facet
23 : public F
24{
25public:
26 static int count;
27
28 explicit my_facet(std::size_t refs = 0)
29 : F(refs) {++count;}
30
31 ~my_facet() {--count;}
32};
33
34int my_facet::count = 0;
35
36int main(int, char**)
37{
38 {
39 std::locale l(std::locale::classic(), new my_facet);
40 assert(my_facet::count == 1);
41 }
42 assert(my_facet::count == 0);
43 {
44 my_facet f(1);
45 assert(my_facet::count == 1);
46 {
47 std::locale l(std::locale::classic(), &f);
48 assert(my_facet::count == 1);
49 }
50 assert(my_facet::count == 1);
51 }
52 assert(my_facet::count == 0);
53
54 return 0;
55}
56

source code of libcxx/test/std/localization/locale.categories/category.time/locale.time.put/ctor.pass.cpp