Files
swift-mirror/test/Interop/Cxx/stdlib/Inputs/std-optional.h
Egor Zhdan c167f4045b [cxx-interop] Conform std::optional to ExpressibleByNilLiteral
This will allow passing `nil` as a parameter to a C++ function that takes a `std::optional<T>`.

rdar://114194600
2023-08-21 19:21:40 +01:00

18 lines
592 B
C++

#ifndef TEST_INTEROP_CXX_STDLIB_INPUTS_STD_OPTIONAL_H
#define TEST_INTEROP_CXX_STDLIB_INPUTS_STD_OPTIONAL_H
#include <optional>
#include <string>
using StdOptionalInt = std::optional<int>;
using StdOptionalString = std::optional<std::string>;
inline StdOptionalInt getNonNilOptional() { return {123}; }
inline StdOptionalInt getNilOptional() { return {std::nullopt}; }
inline bool takesOptionalInt(std::optional<int> arg) { return (bool)arg; }
inline bool takesOptionalString(std::optional<std::string> arg) { return (bool)arg; }
#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_OPTIONAL_H