Allow creation of box and ref through std::unique_ptr and std::shared_ptr respectively

This commit is contained in:
Patrick Urbanke
2024-03-31 11:40:22 +02:00
parent 4fa84ffd30
commit 86f73123d2
6 changed files with 76 additions and 2 deletions
+27
View File
@@ -0,0 +1,27 @@
#include <cassert>
#include <iostream>
#include <rfl.hpp>
#include <rfl/json.hpp>
#include <source_location>
#include <string>
#include <vector>
#include "test_box.hpp"
namespace test_box2 {
void test() {
std::cout << std::source_location::current().function_name() << std::endl;
auto ptr = std::make_unique<std::string>("Hello World!");
const rfl::Result<rfl::Box<std::string>> box =
rfl::make_box<std::string>(std::move(ptr));
if (box) {
std::cout << "OK" << std::endl << std::endl;
} else {
std::cout << "Expected the result to be successful." << std::endl
<< std::endl;
}
}
} // namespace test_box2