Files
scylladb/utils/source_location-compat.hh
Nadav Har'El 09a3c63345 cross-tree: allow std::source_location in clang 14
We recently (commit 6a5d9ff261) started
to use std::source_location instead of std::experimental::source_location.
However, this does not work on clang 14, because libc++ 12's
<source_location> only works if __builtin_source_location, and that is
not available on clang 14.

clang 15 is just three months old, and several relatively-recent
distributions still carry clang 14 so it would be nice to support it
as well.

So this patch adds a trivial compatibility header file, which, when
included and compiled with clang 14, it aliases the functional
std::experimental::source_location to std::source_location.

It turns out it's enough to include the new header file from three
headers that included <source_location> -  I guess all other uses
of source_location depend on those header files directly or indirectly.
We may later need to include the compatibility header file in additional
places, bug for now we don't.

Refs #12259

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

Closes #12265
2022-12-11 20:28:49 +02:00

25 lines
540 B
C++

/*
* Copyright (C) 2022-present ScyllaDB
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
// Define std::source_location, introduced in clang 15, even in clang 14
// where it was called std::experimental::source_location.
//
// When we don't need to support clang 14 any more, this file and all
// its inclusions can be removed.
#pragma once
#if defined(__clang_major__) && __clang_major__ <= 14
#include <experimental/source_location>
namespace std {
using source_location = std::experimental::source_location;
}
#endif