kokkos / stdBLAS

Reference Implementation for stdBLAS
Other
118 stars 22 forks source link

Question regarding conj_if_needed #246

Closed stigrs closed 2 years ago

stigrs commented 2 years ago

At line 87 in conjugated_if_needed.hpp, conj_if_needed is implemented as:

auto conj_if_needed = [](const auto& t)
{
  using T = std::remove_const_t<decltype(t)>;
  return conj_if_needed_impl(t, has_conj<T>{});
};

Is this code missing template <class T> or inline? As the code is now, it will be defined multiple times.

mhoemmen commented 2 years ago

Hi @stigrs ! You're right about the lambda -- it needs inline so as not to break ODR.

Use of auto as one of the parameters makes the lambda a "generic lambda," which means that its operator() is templated, so we don't have to worry about ODR for that. However, the lambda itself needs auto.

mhoemmen commented 2 years ago

@stigrs Thanks for pointing this out! I've pushed a commit to PR #245 that fixes this.