Hi, it is a bit unclear why the example in readme show the use of optional_ref.
The example in question is as follows:
#include <Beman/Optional26/optional.hpp>
...
{
// Empty optional example.
std::optional<int> std_empty_opt;
beman::optional26::optional<int> beman_empty_opt;
assert(!std_empty_opt.has_value() &&
!beman_empty_opt.has_value()); // or assert(!std_empty_opt && !beman_empty_opt);
std::cout << "std_vs_beman: .has_value() matches?: "
<< (std_empty_opt.has_value() == beman_empty_opt.has_value() ? "yes" : "no") << "\n";
}
{
// Optional with value example.
std::optional<int> std_opt = 26;
beman::optional26::optional<int> beman_opt = 26;
assert(std_opt.has_value() && beman_opt.has_value()); // or assert(std_opt && beman_opt);
assert(std_opt.value() == beman_opt.value()); // or assert(*std_opt == *beman_opt);
std::cout << "std_vs_beman: .value() matches?: " << (std_opt.value() == beman_opt.value() ? "yes" : "no")
<< "\n";
}
The values are assigned as values, and the template type of optional in the example is all int, is int& intended to be here instead?
Hi, it is a bit unclear why the example in readme show the use of optional_ref.
The example in question is as follows:
The values are assigned as values, and the template type of optional in the example is all
int, isint&intended to be here instead?