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