You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I understand correctly, bn::optional<T>::emplace() is the only option to create a bn::optional<T> object which contains actual value, when T contains const member variable(s). std::optional<T>::emplace() supports this, but bn::optional<T>::emplace() doesn't.
Because bn::optional<T>::emplace() uses operator= internally, but T can't have assignment operators, as it has const member variable(s).
bn::optional
#include"bn_core.h"
#include"bn_log.h"
#include"bn_optional.h"classTest
{
constint num_;
public:Test(int num) : num_(num) {}
intGetNum() const { return num_; }
};
intmain()
{
bn::core::init();
bn::optional<Test> a;
// error: use of deleted function 'Test& Test::operator=(Test&&)'
a.emplace(42);
BN_LOG(a->GetNum());
while (true)
bn::core::update();
}
If I understand correctly,
bn::optional<T>::emplace()
is the only option to create abn::optional<T>
object which contains actual value, whenT
contains const member variable(s).std::optional<T>::emplace()
supports this, butbn::optional<T>::emplace()
doesn't.Because
bn::optional<T>::emplace()
usesoperator=
internally, butT
can't have assignment operators, as it has const member variable(s).bn::optional
std::optional
The text was updated successfully, but these errors were encountered: