+ bool push(F&& prep, P&&... params) {
+ if (elems_ == nullptr) return false;
+ return elems_->push(this, [&](void* p) {
+ if (prep(p)) ::new (p) T(std::forward(params)...);
+ });
+ }
+
+ template
+ bool force_push(F&& prep, P&&... params) {
+ if (elems_ == nullptr) return false;
+ return elems_->force_push(this, [&](void* p) {
+ if (prep(p)) ::new (p) T(std::forward(params)...);
+ });
+ }
+
+ template
+ bool pop(T& item, F&& out) {
+ if (elems_ == nullptr) {
+ return false;
+ }
+ return elems_->pop(this, &(this->cursor_), [&item](void* p) {
+ ::new (&item) T(std::move(*static_cast(p)));
+ }, std::forward(out));
+ }
+};
+
+} // namespace detail
+
+template
+class queue final : public detail::queue_base> {
+ using base_t = detail::queue_base>;
+
+public:
+ using value_t = T;
+
+ using base_t::base_t;
+
+ template
+ bool push(P&&... params) {
+ return base_t::template push(std::forward(params)...);
+ }
+
+ template
+ bool force_push(P&&... params) {
+ return base_t::template force_push(std::forward(params)...);
+ }
+
+ bool pop(T& item) {
+ return base_t::pop(item, [](bool) {});
+ }
+
+ template
+ bool pop(T& item, F&& out) {
+ return base_t::pop(item, std::forward(out));
+ }
+};
+
+} // namespace ipc
diff --git a/crazy_functions/test_project/cpp/cppipc/shm.cpp b/crazy_functions/test_project/cpp/cppipc/shm.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..92f96ef4c9e7dc31fcd2985d3ac8d1f1546c93a9
--- /dev/null
+++ b/crazy_functions/test_project/cpp/cppipc/shm.cpp
@@ -0,0 +1,103 @@
+
+#include
+#include
+
+#include "libipc/shm.h"
+
+#include "libipc/utility/pimpl.h"
+#include "libipc/memory/resource.h"
+
+namespace ipc {
+namespace shm {
+
+class handle::handle_ : public pimpl {
+public:
+ shm::id_t id_ = nullptr;
+ void* m_ = nullptr;
+
+ ipc::string n_;
+ std::size_t s_ = 0;
+};
+
+handle::handle()
+ : p_(p_->make()) {
+}
+
+handle::handle(char const * name, std::size_t size, unsigned mode)
+ : handle() {
+ acquire(name, size, mode);
+}
+
+handle::handle(handle&& rhs)
+ : handle() {
+ swap(rhs);
+}
+
+handle::~handle() {
+ release();
+ p_->clear();
+}
+
+void handle::swap(handle& rhs) {
+ std::swap(p_, rhs.p_);
+}
+
+handle& handle::operator=(handle rhs) {
+ swap(rhs);
+ return *this;
+}
+
+bool handle::valid() const noexcept {
+ return impl(p_)->m_ != nullptr;
+}
+
+std::size_t handle::size() const noexcept {
+ return impl(p_)->s_;
+}
+
+char const * handle::name() const noexcept {
+ return impl(p_)->n_.c_str();
+}
+
+std::int32_t handle::ref() const noexcept {
+ return shm::get_ref(impl(p_)->id_);
+}
+
+void handle::sub_ref() noexcept {
+ shm::sub_ref(impl(p_)->id_);
+}
+
+bool handle::acquire(char const * name, std::size_t size, unsigned mode) {
+ release();
+ impl(p_)->id_ = shm::acquire((impl(p_)->n_ = name).c_str(), size, mode);
+ impl(p_)->m_ = shm::get_mem(impl(p_)->id_, &(impl(p_)->s_));
+ return valid();
+}
+
+std::int32_t handle::release() {
+ if (impl(p_)->id_ == nullptr) return -1;
+ return shm::release(detach());
+}
+
+void* handle::get() const {
+ return impl(p_)->m_;
+}
+
+void handle::attach(id_t id) {
+ if (id == nullptr) return;
+ release();
+ impl(p_)->id_ = id;
+ impl(p_)->m_ = shm::get_mem(impl(p_)->id_, &(impl(p_)->s_));
+}
+
+id_t handle::detach() {
+ auto old = impl(p_)->id_;
+ impl(p_)->id_ = nullptr;
+ impl(p_)->m_ = nullptr;
+ impl(p_)->s_ = 0;
+ impl(p_)->n_.clear();
+ return old;
+}
+
+} // namespace shm
+} // namespace ipc
diff --git a/crazy_functions/test_project/cpp/cppipc/waiter.h b/crazy_functions/test_project/cpp/cppipc/waiter.h
new file mode 100644
index 0000000000000000000000000000000000000000..ee45fe3517be95ac1688a3e3540189edeb0d860c
--- /dev/null
+++ b/crazy_functions/test_project/cpp/cppipc/waiter.h
@@ -0,0 +1,83 @@
+#pragma once
+
+#include