//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // locale() throw(); #include #include #include int new_called = 0; void* operator new(std::size_t s) throw(std::bad_alloc) { ++new_called; return std::malloc(s); } void operator delete(void* p) throw() { --new_called; std::free(p); } void check(const std::locale& loc) { assert(std::has_facet >(loc)); assert(std::has_facet >(loc)); assert(std::has_facet >(loc)); assert(std::has_facet >(loc)); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); assert((std::has_facet >(loc))); } int main() { int ok; { std::locale loc; assert(new_called == 0); assert(loc.name() == "C"); assert(new_called == 0); check(loc); assert(new_called == 0); assert(std::locale::global(std::locale("en_US")) == loc); ok = new_called; std::locale loc2; assert(new_called == ok); check(loc2); assert(new_called == ok); assert(loc2 == std::locale("en_US")); assert(new_called == ok); } assert(new_called == ok); }