mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:01:07 +01:00
Provide a Printable CRTP parent to replace HasPrintable templates. (#3166)
With the toolchain splitting namespaces, ostream.h's `operator<<` templates aren't reliably found with name lookup, likely due to the loss of associated namespaces (zygoloid commented on this at https://github.com/carbon-language/carbon-lang/pull/3161#discussion_r1307941999). This is especially a barrier to moving the lex files into `Carbon::Lex`; versus other parts of the toolchain, they contain more printable types which are used cross-namespace, including `Carbon::Testing`. As a consequence, I'm looking at migrating ostream.h to a more reliable approach that doesn't rely as much on everything being in the `Carbon` namespace.
This commit is contained in:
@@ -8,7 +8,8 @@
|
||||
|
||||
#include "testing/base/test_raw_ostream.h"
|
||||
|
||||
namespace Carbon {
|
||||
namespace Carbon::Testing {
|
||||
namespace {
|
||||
|
||||
// These are directly in the Carbon namespace because the defines require it.
|
||||
CARBON_DEFINE_RAW_ENUM_CLASS(TestKind, uint8_t) {
|
||||
@@ -34,8 +35,8 @@ CARBON_DEFINE_ENUM_CLASS_NAMES(TestKind) = {
|
||||
#include "common/enum_base_test.def"
|
||||
};
|
||||
|
||||
namespace Testing {
|
||||
namespace {
|
||||
static_assert(sizeof(TestKind) == sizeof(uint8_t),
|
||||
"Class size doesn't match enum size!");
|
||||
|
||||
TEST(EnumBaseTest, NamesAndConstants) {
|
||||
EXPECT_EQ("Beep", TestKind::Beep.name());
|
||||
@@ -108,5 +109,4 @@ TEST(EnumBaseTest, IntConversion) {
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace Testing
|
||||
} // namespace Carbon
|
||||
} // namespace Carbon::Testing
|
||||
|
||||
Reference in New Issue
Block a user