This commit is contained in:
2023-12-23 22:23:48 +08:00
commit 43ced8bd2a
58 changed files with 5702 additions and 0 deletions

22
ACMOJ-2090.cpp Normal file
View File

@ -0,0 +1,22 @@
#include "2090.hpp"
#include <iostream>
signed main() {
sjtu::any_ptr a = sjtu::make_any_ptr(int(1));
sjtu::any_ptr b = a;
a.unwrap<int>() = 2;
std::cerr << b.unwrap<int>() << std::endl; // 2
b = new std::string;
b.unwrap<std::string>() = "Hello, world!";
std::cerr << b.unwrap<std::string>() << std::endl; // Hello, world!
try {
a.unwrap<std::string>() = "a";
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl; // bad cast
}
return 0;
}