From 4b642cd3ce5c63a450b4df08fadbc5a0349c7be9 Mon Sep 17 00:00:00 2001 From: Mark Hoemmen Date: Tue, 12 Jul 2022 11:25:17 -0600 Subject: [PATCH] Make conj_if_needed inline This avoids any ODR violations for the lambda itself. It's a generic lambda, so we don't have to worry about its operator(). Fixes #246. --- include/experimental/__p1673_bits/conjugate_if_needed.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/experimental/__p1673_bits/conjugate_if_needed.hpp b/include/experimental/__p1673_bits/conjugate_if_needed.hpp index 051fb4ba..e789b01e 100644 --- a/include/experimental/__p1673_bits/conjugate_if_needed.hpp +++ b/include/experimental/__p1673_bits/conjugate_if_needed.hpp @@ -83,8 +83,9 @@ auto conj_if_needed_impl(const T& t, std::true_type) return conj(t); } } - -auto conj_if_needed = [](const auto& t) + +// Inline static variables require C++17. +constexpr inline auto conj_if_needed = [](const auto& t) { using T = std::remove_const_t; return conj_if_needed_impl(t, has_conj{});