gpt4 book ai didi

c++ - 如何将 boost::optional 设置回未初始化状态?

转载 作者:IT老高 更新时间:2023-10-28 14:00:28 24 4
gpt4 key购买 nike

如何“重置”/“取消设置”boost::optional

optional<int> x;

if( x )
{
// We won't hit this since x is uninitialized
}
x = 3;
if( x )
{
// Now we will hit this since x has been initialized
}
// What should I do here to bring x back to uninitialized state?
if( x )
{
// I don't want to hit this
}

最佳答案

x = boost::none;

关于c++ - 如何将 boost::optional 设置回未初始化状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8958348/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com