stdoptional

    6热度

    1回答

    我尝试使用std ::可选的,但我的代码引发错误。 我指定#include <experimental/optional>和编译器选项-std=c++1z,-lc++experimental。 如何使用std::experimental::optional? 以下是代码: #include <experimental/optional> #include <iostream> std::ex

    1热度

    2回答

    我有运行时错误,当使用的std ::可选更换了一些代码: 旧代码: T getValue(); ... const auto& value = getValue(); value.get(); 新代码: std::optional<T> getValue(); ... const auto& value = getValue().value(); value.get(); // R

    -6热度

    1回答

    我没有安装最新的编译器,以获得最终的std::optional语义将要发生的提示。但在C++ 14中,有以下几种: #include <experimental/optional> #include <algorithm> int main() { using oint = std::experimental::optional<int>; int x = std::m