Previous fileTop of DocumentContentsIndex pageNext file
Apache C++ Standard Library Reference Guide

operator new

Library:  Language support


Function

Local Index

Non-Members

Summary

Storage allocation functions implicitly called by the corresponding new expressions to allocate storage suitably aligned to construct any object of a given size

Synopsis

#include <new>

namespace std {
    class bad_alloc;
    struct nothrow_t {};
    extern const nothrow_t nothrow;
    typedef void (*new_handler)();
    new_handler set_new_handler new_handler) throw();
}

void* operator new(std::size_t) throw (std::bad_alloc);
void* operator new(std::size_t, const std::nothrow_t&) 
        throw();
void* operator new[](std::size_t) throw(std::bad_alloc);
void* operator new[](std::size_t, const std::nothrow_t&)
        throw();
void* operator new(std::size_t, void*) throw();
void* operator new[](std::size_t, void*) throw();

Description

The library provides definitions for six overloads of the global operator new. The functions are implicitly called as the first step during the evaluation of the corresponding new expression to allocate storage suitably aligned to construct one or more objects (for the array versions of the operator) of any type. The functions indicate failure by either throwing an exception object of type bad_alloc or by returning the null pointer. Replacements for the replaceable forms of the functions should always paired with the replacements for the corresponding overload of operator delete.

Global Functions

new_handler 
set_new_handler(new_handler handler) throw(); 

Global Operators

void* operator new(std::size_t n) throw(std::bad_alloc); 
void* operator new(std::size_t n, const std::nothrow_t&) throw(); 
void* operator new[](std::size_t n) throw(std::bad_alloc); 
void* operator new[](std::size_t, const std::nothrow_t&) throw(); 
void* operator new(std::size_t, void *p) throw(); 
void* operator new[](std::size_t, void *p) throw(); 

See Also

<new>, bad_alloc, operator delete

Standards Conformance

ISO/IEC 14882:1998 -- International Standard for Information Systems -- Programming Language C++, Section 18.4



Previous fileTop of DocumentContentsIndex pageNext file