Debian Codegraph @

libcxx/test/libcxx-03/localization/locales/use_facet.abort.pass.cpp

raw
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 // template <class Facet> const Facet& use_facet(const locale& loc);
12
13 // REQUIRES: no-exceptions
14
15 // Make sure we abort() when we pass a facet not associated to the locale to
16 // use_facet() and exceptions are disabled.
17
18 #include <csignal>
19 #include <cstdlib>
20 #include <locale>
21
22 #include "test_macros.h"
23
24
25 struct my_facet : public std::locale::facet {
26 static std::locale::id id;
27 };
28
29 std::locale::id my_facet::id;
30
31 void exit_success(int) {
32 std::_Exit(EXIT_SUCCESS);
33 }
34
35 int main(int, char**) {
36 std::signal(SIGABRT, exit_success);
37 std::use_facet<my_facet>(std::locale());
38 return EXIT_FAILURE;
39 }