Skip to content

Commit 10ae650

Browse files
authored
Avoid ambiguity in function name (#11914)
Apple clang version 15.0.0 (clang-1500.0.40.1) complains about inject being ambiguous, and indeed it's not clear to me how this could have worked in the first place. Reworked to split the implementation in two, and select the injectBool version only for the case in which there is a single header.
1 parent 5bb1c55 commit 10ae650

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

  • DataFormats/Headers/include/Headers

DataFormats/Headers/include/Headers/Stack.h

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
namespace o2
1818
{
19+
1920
namespace header
2021
{
2122
//__________________________________________________________________________________________________
@@ -103,7 +104,11 @@ struct Stack {
103104
bufferSize{calculateSize(std::forward<Headers>(headers)...)},
104105
buffer{static_cast<std::byte*>(allocator.resource()->allocate(bufferSize, alignof(std::max_align_t))), freeobj{allocator.resource()}}
105106
{
106-
inject(buffer.get(), std::forward<Headers>(headers)...);
107+
if constexpr (sizeof...(headers) > 1) {
108+
injectAll(buffer.get(), std::forward<Headers>(headers)...);
109+
} else if (sizeof...(headers) == 1) {
110+
injectBool(buffer.get(), std::forward<Headers>(headers)..., false);
111+
}
107112
}
108113

109114
//______________________________________________________________________________________________
@@ -144,7 +149,7 @@ struct Stack {
144149

145150
//______________________________________________________________________________________________
146151
template <typename T>
147-
static std::byte* inject(std::byte* here, T&& h, bool more = false) noexcept
152+
static std::byte* injectBool(std::byte* here, T&& h, bool more) noexcept
148153
{
149154
using headerType = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
150155
if (here == nullptr) {
@@ -189,11 +194,15 @@ struct Stack {
189194

190195
//______________________________________________________________________________________________
191196
template <typename T, typename... Args>
192-
static std::byte* inject(std::byte* here, T&& h, Args&&... args) noexcept
197+
static std::byte* injectAll(std::byte* here, T&& h, Args&&... args) noexcept
193198
{
194199
bool more = hasNonEmptyArg(args...);
195-
auto alsohere = inject(here, h, more);
196-
return inject(alsohere, args...);
200+
auto alsohere = injectBool(here, h, more);
201+
if constexpr (sizeof...(args) > 1) {
202+
return injectAll(alsohere, args...);
203+
} else {
204+
return injectBool(alsohere, args..., false);
205+
}
197206
}
198207

199208
//______________________________________________________________________________________________

0 commit comments

Comments
 (0)