Files
swift-mirror/test/Interop/Cxx/stdlib/Inputs/std-set.h
Egor Zhdan 6366878308 [cxx-interop] Add CxxSet protocol for std::set ergonomics
This adds a protocol to the C++ standard library overlay which will improve the ergonomics of `std::set`, `std::unordered_set` and `std::multiset` when used from Swift code.

As of now, `CxxSet` adds a `contains` function to C++ sets.

C++ stdlib set types are automatically conformed to `CxxSet`: `std::set`, `unordered_set`, `std::multiset`. Custom user types are not conformed to `CxxSet` automatically: while a custom type might have an interface similar to `std::set`, the semantics might differ, and adding a conformance would cause confusion.
2023-01-26 19:35:30 +00:00

16 lines
517 B
C++

#ifndef TEST_INTEROP_CXX_STDLIB_INPUTS_STD_SET_H
#define TEST_INTEROP_CXX_STDLIB_INPUTS_STD_SET_H
#include <set>
#include <unordered_set>
using SetOfCInt = std::set<int>;
using UnorderedSetOfCInt = std::unordered_set<int>;
using MultisetOfCInt = std::multiset<int>;
inline SetOfCInt initSetOfCInt() { return {1, 5, 3}; }
inline UnorderedSetOfCInt initUnorderedSetOfCInt() { return {2, 4, 6}; }
inline MultisetOfCInt initMultisetOfCInt() { return {2, 2, 4, 6}; }
#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_SET_H