blob: c6cc57c9ed95afff4a1de633a7b77b6c9072aa6f [file] [log] [blame]
// checking for operator new (size_t, nothrow_t)
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the License); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* implied. See the License for the specific language governing
* permissions and limitations under the License.
* Copyright 1999-2007 Rogue Wave Software, Inc.
* This and related operator comptests are necessarily complicated
* due to the possibility that the nothrow versions of the operators
* may be defined in the compiler's language support library in the
* global namespace rather than in namespace std.
* STD_NOTHROW_T.cpp, checks if operator new(size_t, std::nothrow_t)
* is defined in the language support library. If it isn't,
* GLOBAL_NOTHROW_T.cpp checks if operator new(size_t, ::nothrow_t)
* is defined. In each of the tests that follow, we define nothrow_t
* in the namespace in which it resides in the support library, and
* in the case that it was defined in the std namespace, we bring
* it into the the global namespace with a using declaration.
* This way we can use the same form for both cases.
* [Note: We make the assumption that all of the nothrow versions
* of the operators will use the same signature.]
#include "config.h"
#include <stddef.h> // for size_t
namespace std {
struct nothrow_t { };
} // end namespace std
using std::nothrow_t;
# define throw()
void* operator new (size_t, const nothrow_t&) throw ();
int main ()
::operator new (1, nothrow_t ());
return 0;