[COMMIT osv master] Remove redundant template name from method definition

0 views
Skip to first unread message

Commit Bot

unread,
Jun 28, 2024, 10:53:43 AM (5 days ago) Jun 28
to osv...@googlegroups.com, Nadav Har'El
From: Nadav Har'El <n...@scylladb.com>
Committer: Nadav Har'El <n...@scylladb.com>
Branch: master

Remove redundant template name from method definition

When defining a method and especially a constructor in a templated class
c<T>, there is no need to use the "<T>" to "disambiguate" the name of
the method or constructors. This "disambiguation" syntax used to work but was
outlawed in C++20 (see https://stackoverflow.com/questions/63513984)
and doesn't compile with gcc 14.1.1, giving the error:

include/lockfree/queue-mpsc.hh:39:19: error: template-id not allowed for constructor in C++20 [-Werror=template-id-cdtor]
39 | linked_item<T>() : value(), next(nullptr) { }

This patch removes the unnecessary "disambiguations" and fixes a part of
the build on gcc 14.1.1 (e.g., on Fedora 40). There are other problems
too, which will be solved in the following patches.

Signed-off-by: Nadav Har'El <n...@scylladb.com>

---
diff --git a/include/lockfree/queue-mpsc.hh b/include/lockfree/queue-mpsc.hh
--- a/include/lockfree/queue-mpsc.hh
+++ b/include/lockfree/queue-mpsc.hh
@@ -36,8 +36,8 @@ class linked_item {
public:
T value;
linked_item<T> *next;
- linked_item<T>() : value(), next(nullptr) { }
- explicit linked_item<T>(T val) : value(val), next(nullptr) { }
+ linked_item() : value(), next(nullptr) { }
+ explicit linked_item(T val) : value(val), next(nullptr) { }
};

// LT can be any type that has an "LT *next" field, which we used to hold a
@@ -48,7 +48,7 @@ private:
std::atomic<LT*> pushlist;
std::atomic<LT*> poplist;
public:
- constexpr queue_mpsc<LT>() : pushlist(nullptr), poplist(nullptr) { }
+ constexpr queue_mpsc() : pushlist(nullptr), poplist(nullptr) { }

class iterator;

diff --git a/include/lockfree/unordered-queue-mpsc.hh b/include/lockfree/unordered-queue-mpsc.hh
--- a/include/lockfree/unordered-queue-mpsc.hh
+++ b/include/lockfree/unordered-queue-mpsc.hh
@@ -27,7 +27,7 @@ private:
std::atomic<LT*> _head CACHELINE_ALIGNED;
LT* _poll_list CACHELINE_ALIGNED;
public:
- constexpr unordered_queue_mpsc<LT>()
+ constexpr unordered_queue_mpsc()
: _head(nullptr)
, _poll_list(nullptr)
{
Reply all
Reply to author
Forward
0 new messages