Skip to content

Commit 62ffdf2

Browse files
committed
Move OptionSet to its own namespace
The type was colliding with the `OptionSet` type in the Swift stdlib when using Swift from C++.
1 parent eee45f7 commit 62ffdf2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

include/swift/Basic/OptionSet.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
#include <initializer_list>
2525

2626
namespace swift {
27+
/// The Swift standard library also has an `OptionSet` type that is imported
28+
/// when using C++ to Swift interop within the compiler.
29+
/// Since the Swift stdlib is also imported in the `swift` namespace, the two
30+
/// types would conflict. Move the compiler's OptionSet into a sub-namespace
31+
/// to avoid collisions. Below we do `using namespace optionset`, which makes
32+
/// the C++ `OptionSet` type available everywhere the `swift` namespace is used.
33+
namespace optionset {
2734

2835
/// The class template \c OptionSet captures a set of options stored as the
2936
/// bits in an unsigned integral value.
@@ -151,7 +158,8 @@ class OptionSet {
151158
Flags>::value,
152159
"operator| should produce an OptionSet");
153160
};
154-
161+
} // end namespace optionset
162+
using namespace optionset;
155163
} // end namespace swift
156164

157165
#endif // SWIFT_BASIC_OPTIONSET_H

0 commit comments

Comments
 (0)