Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions test/Interop/Cxx/stdlib/Inputs/module.modulemap
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
module StdAny {
header "std-any.h"
requires cplusplus
export *
}

module StdNumeric {
header "std-numeric.h"
requires cplusplus
Expand Down
6 changes: 6 additions & 0 deletions test/Interop/Cxx/stdlib/Inputs/std-any.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include <any>
#include <string>

inline std::any getStdAnyString() {
return std::string("abc210");
}
23 changes: 23 additions & 0 deletions test/Interop/Cxx/stdlib/use-std-any.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift)
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++17)
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++20)

// REQUIRES: executable_test

// In Microsoft STL, all overloads of std::any_cast return a dependent templated
// type, which Swift isn't able to instantiate.
// UNSUPPORTED: OS=windows-msvc

import StdlibUnittest
import StdAny
import CxxStdlib

var StdAnyTestSuite = TestSuite("StdAny")

StdAnyTestSuite.test("std.any_cast<std.string>") {
let a1 = getStdAnyString()
let c1 = std.any_cast(a1) as std.string
expectEqual(c1, std.string("abc210"))
}

runAllTests()