Skip to content

Commit

Permalink
Let GeneratedMessageTraits use C++17 feature of auto template arguments.
Browse files Browse the repository at this point in the history
This is mostly a style fix so that we can avoid using decltype which is a bit
cumbersome. auto template arguments is a C++17 feature so we can only do this
after we've migrated the buildchain to use C++17.

We upgraded main branch to C++17 in commit
fe53593

PiperOrigin-RevId: 706015756
  • Loading branch information
tonyliaoss authored and copybara-github committed Dec 13, 2024
1 parent f4cc92c commit 0176416
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/google/protobuf/compiler/cpp/file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1503,9 +1503,8 @@ class FileGenerator::ForwardDeclarations {
if (options.dllexport_decl.empty()) {
p->Emit(R"cc(
template <>
internal::GeneratedMessageTraitsT<
decltype($default_name$), &$default_name$,
decltype($class$_class_data_), &$class$_class_data_>
internal::GeneratedMessageTraitsT<&$default_name$,
&$class$_class_data_>
internal::MessageTraitsImpl::value<$class$>;
)cc");
}
Expand Down
4 changes: 1 addition & 3 deletions src/google/protobuf/message_lite.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,7 @@ class PROTOBUF_EXPORT CachedSize {

auto GetClassData(const MessageLite& msg);

// TODO: Upgrade to `auto` parameters when we drop C++14 support.
template <typename T, const T* kDefault, typename ClassData,
const ClassData* kClassData>
template <const auto* kDefault, const auto* kClassData>
struct GeneratedMessageTraitsT {
static constexpr const void* default_instance() { return kDefault; }
static constexpr const auto* class_data() { return kClassData->base(); }
Expand Down

0 comments on commit 0176416

Please sign in to comment.