Are there STL implementations that use operator new[] as an allocator? I was just wondering because on my compiler, making Foo::operator new[] private did not prevent me from creating a vector<Foo>... is that behavior guaranteed by anything?
...
I'm having some trouble with a dynamically linked library calling my overloaded operator delete but not my operator new. My exe looks something like this:
class A {
public:
void func() {
t = dynLib::Type::CreateObject();
}
dynLib::Type t;
};
void main() {
A a;
a.func();
}
And then I have a statically linke...
For a class without default constructor, operator new and placement new can be used to declare an array of such class.
When I read the code in More Effective C++, I found the code as below(I modified some part).....
My question is, why [] after the operator new is needed?
I test it without it, it still works. Can any body explain th...
I'm trying to wrap a class from a library I'm using in Lua. Specifially, I'm trying to wrap the color class from SFML. The full source for the color class can be seen here and here.
This is the function that's that I'm failing in.
int SFColor_new(lua_State* L)
{
// omitting part where I set r, g, b, and a
new (lua_newuserdata...
I was thinking about some memory pool/allocation stuff I might write so I came up with this operator new overload that I want to use to facilitate reuse of memory. I'm wondering if there are any problems you guys can think of with my implementation (or any other possible ones).
#include <cstddef>
namespace ns {
struct renew_t { };
...
Wikipedia states:
A type can be made impossible to allocate with operator new:
struct NonNewable {
void *operator new(std::size_t) = delete;
};
An object of this type can only ever be allocated as a stack object or as a member of another type. It cannot be directly heap-allocated without non-portable trickery. (Since place...