has_facet.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <locale>
11
12// template <class Facet> bool has_facet(const locale& loc) throw();
13
14#include <locale>
15#include <cassert>
16
17struct my_facet
18    : public std::locale::facet
19{
20    static std::locale::id id;
21};
22
23std::locale::id my_facet::id;
24
25int main()
26{
27    std::locale loc;
28    assert(std::has_facet<std::ctype<char> >(loc));
29    assert(!std::has_facet<my_facet>(loc));
30    std::locale loc2(loc, new my_facet);
31    assert(std::has_facet<my_facet>(loc2));
32}
33