CARVIEW |
Select Language
HTTP/2 200
date: Tue, 14 Oct 2025 21:05:27 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=7f1380028896f4f8600b7c43e064e49e330985f444f396e659e63b6bb2baa86ea%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22CFXtp1uRfDHTRyM2qRB5EwOHhlplm7FV%22%3B%7D; HttpOnly; Path=/
cf-ray: 98ea08f1d90a165e-BLR
kinda c++ rust things - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- template <typename T>
- struct const_ref;
- template <typename T>
- struct mut_ref;
- struct unsafe_op {};
- template <typename T>
- struct safe_ptr {
- long refcnt;
- T *data;
- safe_ptr() : refcnt(0), data(new T) {}
- safe_ptr(T val) : refcnt(0), data(new T) {
- *data = val;
- }
- ~safe_ptr() { delete data; }
- safe_ptr(safe_ptr const&) = delete;
- const_ref<T> operator &() {
- if (refcnt >= 0)
- return const_ref<T>{this};
- else
- throw unsafe_op{};
- }
- mut_ref<T> operator +() {
- if (refcnt == 0)
- return mut_ref<T>{this};
- else
- throw unsafe_op{};
- }
- };
- template <typename T>
- struct const_ref {
- safe_ptr<T>& ptr;
- const_ref(safe_ptr<T> *upstream)
- : ptr(*upstream) {
- ptr.refcnt += 1;
- }
- ~const_ref() {
- ptr.refcnt -= 1;
- }
- T const& operator *() {
- return *ptr.data;
- }
- };
- template <typename T>
- struct mut_ref {
- safe_ptr<T>& ptr;
- mut_ref(safe_ptr<T> *upstream)
- : ptr(*upstream) {
- ptr.refcnt -= 1;
- }
- ~mut_ref() {
- ptr.refcnt += 1;
- }
- T& operator *() {
- return *ptr.data;
- }
- };
- int main() {
- safe_ptr<int> x { 1 };
- {
- auto ref = &x;
- // *ref = 100; // would fail for modification of const
- auto ref2 = &x;
- printf("%i", *ref, *ref2);
- // auto mut_ref = +x; // would fail for taking mutable ref while const refs exist
- }
- {
- auto mut_ref = +x;
- *mut_ref = 10;
- }
- {
- auto ref = &x;
- printf("%i", *ref);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
💡 EASY MONEY GUIDE ✅ Working
JavaScript | 6 sec ago | 0.24 KB
-
✅ Marketplace Glitch ✅ Working NEVER SEEN BE...
JavaScript | 6 sec ago | 0.25 KB
-
⭐⭐⭐Exploit 500$ in 15 Minutes⭐⭐
Java | 8 sec ago | 0.15 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ X
JavaScript | 14 sec ago | 0.25 KB
-
⚡ Crypto Swap Glitch ✅ Working ⚡
JavaScript | 15 sec ago | 0.24 KB
-
⭐⭐⭐Exploit 500$ in 15 Minutes⭐⭐
Java | 19 sec ago | 0.15 KB
-
💵 Make 3000$ in 20 minutes 💵
JavaScript | 24 sec ago | 0.24 KB
-
📌 Instant BTC Profit Method ✅ Working 7
JavaScript | 25 sec ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand