Lines Matching defs:new
120 static TestFactory1 *construct1() { return new TestFactory1(); }
122 static std::unique_ptr<TestFactory1> construct1(int a) { return std::unique_ptr<TestFactory1>(new TestFactory1(a)); }
124 static TestFactory1 *construct1_string(std::string a) { return new TestFactory1(a); }
128 static TestFactory2 *construct2() { return new TestFactory2(); }
130 static std::unique_ptr<TestFactory2> construct2(int a) { return std::unique_ptr<TestFactory2>(new TestFactory2(a)); }
136 static TestFactory3 *construct3() { return new TestFactory3(); }
138 static std::shared_ptr<TestFactory3> construct3(int a) { return std::shared_ptr<TestFactory3>(new TestFactory3(a)); }
180 auto c4a = [c](pointer_tag, TF4_tag, int a) { (void) c; return new TestFactory4(a);};
186 .def("__init__", [](TestFactory3 &self, std::string v) { new (&self) TestFactory3(v); }) // placement-new ctor
190 .def(py::init([](pointer_tag, TF5_tag, int a) { return new TestFactory5(a); }))
215 .def(py::init([](alias_tag, pointer_tag, int i) { return new PyTF6(i); }))
216 .def(py::init([](base_tag, pointer_tag, int i) { return new TestFactory6(i); }))
217 .def(py::init([](base_tag, alias_tag, pointer_tag, int i) { return (TestFactory6 *) new PyTF6(i); }))
233 [](pointer_tag, int i) { return new TestFactory7(i); },
234 [](pointer_tag, int i) { return new PyTF7(i); }))
236 [](mixed_tag, int i) { return new TestFactory7(i); },
240 [](mixed_tag, std::string s) { return new PyTF7((int) s.size()); }))
242 [](base_tag, pointer_tag, int i) { return new TestFactory7(i); },
243 [](base_tag, pointer_tag, int i) { return (TestFactory7 *) new PyTF7(i); }))
245 [](alias_tag, pointer_tag, int i) { return new PyTF7(i); },
246 [](alias_tag, pointer_tag, int i) { return new PyTF7(10*i); }))
249 [](shared_ptr_tag, base_tag, int i) { auto *p = new PyTF7(i); return std::shared_ptr<TestFactory7>(p); }))
262 // Class with a custom new operator but *without* a placement new operator (issue #948)
266 static void *operator new(std::size_t s) {
267 auto *p = ::operator new(s);
268 py::print("operator new called, returning", reinterpret_cast<uintptr_t>(p));
277 // As of 2.2, `py::init<args>` no longer requires placement new
280 .def(py::init([]() { return new NoPlacementNew(100); }))
293 static void *operator new(size_t s) { py::print("noisy new"); return ::operator new(s); }
294 static void *operator new(size_t, void *p) { py::print("noisy placement new"); return p; }
306 .def("__init__", [](NoisyAlloc *a, int i) { new (a) NoisyAlloc(i); }) // Regular constructor, runs first, requires preallocation
307 .def(py::init([](double d) { return new NoisyAlloc(d); }))
310 .def(py::init([](int i, int) { return new NoisyAlloc(i); }))
313 // Old-style placement new init; requires preallocation
314 .def("__init__", [](NoisyAlloc &a, double d, double) { new (&a) NoisyAlloc(d); })
316 .def(py::init([](int i, double) { return new NoisyAlloc(i); }))
318 .def("__init__", [](NoisyAlloc &a, int i, std::string) { new (&a) NoisyAlloc(i); })
336 bf1.def(py::init([]() { return std::shared_ptr<BadF1Base>(new BadF1()); }));