Apply some clang-tidy 18 fixes (#2762)

This commit is contained in:
Bart Louwers
2024-08-26 16:32:01 +02:00
committed by GitHub
parent cf55873cf9
commit 1bdc3425db
37 changed files with 131 additions and 128 deletions

View File

@@ -1437,21 +1437,11 @@ include(${PROJECT_SOURCE_DIR}/vendor/polylabel.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/protozero.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/tracy.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/unique_resource.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/unordered_dense.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/vector-tile.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/wagyu.cmake)
include(${PROJECT_SOURCE_DIR}/vendor/metal-cpp.cmake)
add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/unordered_dense)
set_target_properties(
unordered_dense
PROPERTIES
INTERFACE_MAPBOX_NAME "unordered_dense"
INTERFACE_MAPBOX_URL "https://github.com/martinus/unordered_dense"
INTERFACE_MAPBOX_AUTHOR "Martin Leitner-Ankerl"
INTERFACE_MAPBOX_LICENSE ${PROJECT_SOURCE_DIR}/vendor/unordered_dense/LICENSE
)
target_link_libraries(
mbgl-core
PRIVATE

View File

@@ -29,11 +29,9 @@ template <class Object>
class EstablishedActor {
public:
// Construct the Object from a parameter pack `args` (i.e. `Object(args...)`)
template <typename U = Object,
class... Args,
typename std::enable_if_t<std::is_constructible_v<U, Args...> ||
std::is_constructible_v<U, ActorRef<U>, Args...>>* = nullptr>
template <typename U = Object, class... Args>
EstablishedActor(Scheduler& scheduler, AspiringActor<Object>& parent_, Args&&... args)
requires(std::is_constructible_v<U, Args...> || std::is_constructible_v<U, ActorRef<U>, Args...>)
: parent(parent_) {
emplaceObject(std::forward<Args>(args)...);
parent.mailbox->open(scheduler);

View File

@@ -148,9 +148,9 @@ public:
/// `emplaceOrUpdateUniformBuffer` with type inference
template <typename T>
std::enable_if_t<!std::is_pointer_v<T>, bool> emplaceOrUpdateUniformBuffer(gfx::UniformBufferPtr& ptr,
const T* data,
bool persistent = false) {
bool emplaceOrUpdateUniformBuffer(gfx::UniformBufferPtr& ptr, const T* data, bool persistent = false)
requires(!std::is_pointer_v<T>)
{
return emplaceOrUpdateUniformBuffer(ptr, data, sizeof(T), persistent);
}

View File

@@ -33,8 +33,10 @@ public:
/// @brief Downcast to a type
/// @tparam T Derived type
/// @return Type or nullptr if type info was not a match
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
T* to() noexcept {
template <typename T>
T* to() noexcept
requires(is_shader_v<T>)
{
if (typeName() != T::Name) {
return nullptr;
}

View File

@@ -93,8 +93,10 @@ public:
/// This variant looks up shaders only by type name.
/// @tparam T Derived type, inheriting `gfx::Shader`
/// @return T or nullptr if not found in the group
template <typename T, typename std::enable_if_t<is_shader_v<T>, bool>* = nullptr>
std::shared_ptr<T> get() noexcept {
template <typename T>
std::shared_ptr<T> get() noexcept
requires(is_shader_v<T>)
{
auto shader = getShader(std::string(T::Name));
if (!shader || shader->typeName() != T::Name) {
return nullptr;

View File

@@ -64,10 +64,9 @@ public:
void createOrUpdate(const size_t id, const std::vector<uint8_t>& data, gfx::Context&, bool persistent = false);
void createOrUpdate(const size_t id, const void* data, std::size_t size, gfx::Context&, bool persistent = false);
template <typename T>
std::enable_if_t<!std::is_pointer_v<T>> createOrUpdate(const size_t id,
const T* data,
gfx::Context& context,
bool persistent = false) {
void createOrUpdate(const size_t id, const T* data, gfx::Context& context, bool persistent = false)
requires(!std::is_pointer_v<T>)
{
createOrUpdate(id, data, sizeof(T), context, persistent);
}

View File

@@ -191,12 +191,12 @@ public:
}
template <std::size_t I = 0, typename... Tp>
inline typename std::enable_if<I == sizeof...(Tp), void>::type set(std::size_t, std::tuple<Tp...>, std::size_t) {}
inline typename std::enable_if_t<I == sizeof...(Tp), void> set(std::size_t, std::tuple<Tp...>, std::size_t) {}
/// Set item value
template <std::size_t I = 0, typename... Tp>
inline typename std::enable_if <
I<sizeof...(Tp), void>::type set(std::size_t i, std::tuple<Tp...> tuple, std::size_t tupleIndex) {
inline typename std::enable_if_t <
I<sizeof...(Tp), void> set(std::size_t i, std::tuple<Tp...> tuple, std::size_t tupleIndex) {
if (tupleIndex == 0) {
set(i, std::get<I>(tuple).a1);
} else {

View File

@@ -8,32 +8,44 @@ namespace mbgl {
namespace util {
template <typename T>
typename std::enable_if_t<std::is_integral_v<T>, T> max(T a, T b) {
T max(T a, T b)
requires(std::is_integral_v<T>)
{
return std::max(a, b);
}
template <typename T>
typename std::enable_if_t<std::is_floating_point_v<T>, T> max(T a, T b) {
T max(T a, T b)
requires(std::is_floating_point_v<T>)
{
return ::fmax(a, b);
}
template <typename T, typename... Ts>
typename std::enable_if_t<std::is_arithmetic_v<T>, T> max(T a, T b, Ts... args) {
T max(T a, T b, Ts... args)
requires(std::is_arithmetic_v<T>)
{
return max(a, max(b, args...));
}
template <typename T>
typename std::enable_if_t<std::is_integral_v<T>, T> min(T a, T b) {
T min(T a, T b)
requires(std::is_integral_v<T>)
{
return std::min(a, b);
}
template <typename T>
typename std::enable_if_t<std::is_floating_point_v<T>, T> min(T a, T b) {
T min(T a, T b)
requires(std::is_floating_point_v<T>)
{
return ::fmin(a, b);
}
template <typename T, typename... Ts>
typename std::enable_if_t<std::is_arithmetic_v<T>, T> min(T a, T b, Ts... args) {
T min(T a, T b, Ts... args)
requires(std::is_arithmetic_v<T>)
{
return min(a, min(b, args...));
}

View File

@@ -282,9 +282,11 @@ protected:
return *lhs == *rhs;
}
template <typename T, typename = std::enable_if_t<std::is_scalar_v<T>>>
template <typename T>
static bool childEqual(const std::pair<T, std::unique_ptr<Expression>>& lhs,
const std::pair<T, std::unique_ptr<Expression>>& rhs) noexcept {
const std::pair<T, std::unique_ptr<Expression>>& rhs) noexcept
requires(std::is_scalar_v<T>)
{
return lhs.first == rhs.first && *(lhs.second) == *(rhs.second);
}
@@ -294,9 +296,11 @@ protected:
return lhs.first == rhs.first && *(lhs.second) == *(rhs.second);
}
template <typename T, typename = std::enable_if_t<!std::is_scalar_v<T>>>
template <typename T>
static bool childEqual(const std::pair<T, std::shared_ptr<Expression>>& lhs,
const std::pair<T, std::shared_ptr<Expression>>& rhs) noexcept {
const std::pair<T, std::shared_ptr<Expression>>& rhs) noexcept
requires(!std::is_scalar_v<T>)
{
#if __clang_major__ > 16
// On older compilers, this assignment doesn't do overload resolution
// in the same way that `lhs==rhs` does and produces ambiguity errors.

View File

@@ -35,7 +35,7 @@ public:
defaultValue.match([&fn](const style::PropertyExpression<T>& e) { fn(e.getExpression()); }, [](const T&) {});
}
bool operator==(const Expression& e) const final override {
bool operator==(const Expression& e) const final {
if (e.getKind() == Kind::FormatSectionOverride) {
const auto* other = static_cast<const FormatSectionOverride*>(&e);

View File

@@ -90,7 +90,9 @@ public:
const expression::EvaluationResult result = expression->evaluate(context);
if (result) {
const std::optional<T> typed = expression::fromExpressionValue<T>(*result);
return typed ? *typed : defaultValue ? *defaultValue : finalDefaultValue;
if (typed) {
return *typed;
}
}
return defaultValue ? *defaultValue : finalDefaultValue;
}

View File

@@ -7,25 +7,25 @@ namespace mbgl {
template <typename Enum>
constexpr Enum operator|(Enum a, Enum b) {
static_assert(std::is_enum<Enum>::value, "Enum must be an enum type");
static_assert(std::is_enum_v<Enum>, "Enum must be an enum type");
return Enum(mbgl::underlying_type(a) | mbgl::underlying_type(b));
}
template <typename Enum>
constexpr Enum& operator|=(Enum& a, Enum b) {
static_assert(std::is_enum<Enum>::value, "Enum must be an enum type");
static_assert(std::is_enum_v<Enum>, "Enum must be an enum type");
return (a = a | b);
}
template <typename Enum>
constexpr bool operator&(Enum a, Enum b) {
static_assert(std::is_enum<Enum>::value, "Enum must be an enum type");
static_assert(std::is_enum_v<Enum>, "Enum must be an enum type");
return bool(mbgl::underlying_type(a) & mbgl::underlying_type(b));
}
template <typename Enum>
constexpr Enum operator~(Enum value) {
static_assert(std::is_enum<Enum>::value, "Enum must be an enum type");
static_assert(std::is_enum_v<Enum>, "Enum must be an enum type");
return Enum(~mbgl::underlying_type(value));
}

View File

@@ -46,11 +46,10 @@ _NODISCARD constexpr std::chrono::duration<_Rep, _Period> abs(const std::chrono:
: _Dur;
}
#else
template <
class Rep,
class Period,
class = std::enable_if_t<std::chrono::duration<Rep, Period>::min() < std::chrono::duration<Rep, Period>::zero()>>
constexpr std::chrono::duration<Rep, Period> abs(std::chrono::duration<Rep, Period> d) {
template <class Rep, class Period>
constexpr std::chrono::duration<Rep, Period> abs(std::chrono::duration<Rep, Period> d)
requires(std::chrono::duration<Rep, Period>::min() < std::chrono::duration<Rep, Period>::zero())
{
return d >= d.zero() ? d : -d;
}
#endif

View File

@@ -11,15 +11,19 @@
namespace mbgl {
namespace util {
template <typename To, typename From, std::size_t Size, typename = std::enable_if_t<std::is_convertible_v<From, To>>>
constexpr std::array<To, Size> convert(const std::array<From, Size>& from) {
template <typename To, typename From, std::size_t Size>
constexpr std::array<To, Size> convert(const std::array<From, Size>& from)
requires(std::is_convertible_v<From, To>)
{
std::array<To, Size> to{{}};
std::copy(std::begin(from), std::end(from), std::begin(to));
return to;
}
template <typename To, typename From, std::size_t Size, typename = std::enable_if_t<std::is_assignable_v<To&, From>>>
constexpr std::array<To, Size> cast(const std::array<From, Size>& from) {
template <typename To, typename From, std::size_t Size>
constexpr std::array<To, Size> cast(const std::array<From, Size>& from)
requires(std::is_assignable_v<To&, From>)
{
std::array<To, Size> to{{}};
std::transform(std::begin(from), std::end(from), std::begin(to), [](From x) { return static_cast<To>(x); });
return to;

View File

@@ -22,11 +22,11 @@ public:
uint32_t height = 0;
};
constexpr inline bool operator==(const Size& a, const Size& b) noexcept {
constexpr bool operator==(const Size& a, const Size& b) noexcept {
return a.width == b.width && a.height == b.height;
}
constexpr inline bool operator!=(const Size& a, const Size& b) noexcept {
constexpr bool operator!=(const Size& a, const Size& b) noexcept {
return !(a == b);
}

View File

@@ -25,13 +25,12 @@ struct is_utf16char_like<uint16_t> : std::true_type {};
template <typename T>
using is_utf16char_like_pointer =
std::integral_constant<bool,
std::is_pointer_v<T> && is_utf16char_like<typename std::remove_pointer<T>::type>::value>;
std::integral_constant<bool, std::is_pointer_v<T> && is_utf16char_like<std::remove_pointer_t<T>>::value>;
template <class OutPointer, class InChar>
typename std::enable_if<is_utf16char_like<InChar>::value && is_utf16char_like_pointer<OutPointer>::value,
OutPointer>::type
utf16char_cast(InChar *in) {
OutPointer utf16char_cast(InChar *in)
requires(is_utf16char_like<InChar>::value && is_utf16char_like_pointer<OutPointer>::value)
{
return reinterpret_cast<OutPointer>(in);
}

View File

@@ -20,7 +20,7 @@ Mailbox::Mailbox(const TaggedScheduler& scheduler_)
void Mailbox::open(const TaggedScheduler& scheduler_) {
assert(!weakScheduler);
schedulerTag = scheduler_.tag;
return open(*scheduler_.get());
open(*scheduler_.get());
}
void Mailbox::open(Scheduler& scheduler_) {

View File

@@ -13,10 +13,12 @@ std::function<void()> Scheduler::bindOnce(std::function<void()> fn) {
};
}
static auto& current() {
namespace {
auto& current() {
static util::ThreadLocal<Scheduler> scheduler;
return scheduler;
}
} // namespace
void Scheduler::SetCurrent(Scheduler* scheduler) {
current().set(scheduler);

View File

@@ -234,12 +234,16 @@ void AnnotationManager::removeTile(AnnotationTile& tile) {
tiles.erase(&tile);
}
namespace {
// To ensure that annotation images do not collide with images from the style,
// we prefix input image IDs with "org.maplibre.annotations".
static std::string prefixedImageID(const std::string& id) {
std::string prefixedImageID(const std::string& id) {
return AnnotationManager::SourceID + "." + id;
}
} // namespace
void AnnotationManager::addImage(std::unique_ptr<style::Image> image) {
CHECK_ANNOTATIONS_ENABLED_AND_RETURN_NOARG();
std::lock_guard<std::mutex> lock(mutex);

View File

@@ -70,7 +70,7 @@ public:
: VertexVectorBase(other),
v(other.v) {}
VertexVector(VertexVector<V>&& other)
: VertexVectorBase(std::move(other)),
: VertexVectorBase(static_cast<VertexVectorBase&&>(other)),
v(std::move(other.v)) {}
~VertexVector() override = default;

View File

@@ -193,15 +193,15 @@ const std::optional<SymbolQuads>& SymbolInstance::iconQuads() const {
}
bool SymbolInstance::hasText() const {
return static_cast<bool>(symbolContent & SymbolContent::Text);
return symbolContent & SymbolContent::Text;
}
bool SymbolInstance::hasIcon() const {
return static_cast<bool>(symbolContent & SymbolContent::IconRGBA) || hasSdfIcon();
return symbolContent & SymbolContent::IconRGBA || hasSdfIcon();
}
bool SymbolInstance::hasSdfIcon() const {
return static_cast<bool>(symbolContent & SymbolContent::IconSDF);
return symbolContent & SymbolContent::IconSDF;
}
const std::optional<SymbolQuads>& SymbolInstance::verticalIconQuads() const {

View File

@@ -266,8 +266,7 @@ std::array<float, 2> evaluateRadialOffset(style::SymbolAnchorType anchor, float
std::array<float, 2> result{{0.0f, 0.0f}};
if (radialOffset < 0.0f) radialOffset = 0.0f; // Ignore negative offset.
// solve for r where r^2 + r^2 = radialOffset^2
const float sqrt2 = 1.41421356237f;
const float hypotenuse = radialOffset / sqrt2;
const float hypotenuse = radialOffset / std::numbers::sqrt2_v<float>;
switch (anchor) {
case SymbolAnchorType::TopRight:

View File

@@ -314,7 +314,7 @@ void Map::setBounds(const BoundOptions& options) {
impl->transform.setMinZoom(*options.minZoom);
if (impl->transform.getZoom() < *options.minZoom) {
changeCamera = true;
cameraOptions.withZoom(*options.minZoom);
cameraOptions.withZoom(options.minZoom);
}
}
@@ -322,7 +322,7 @@ void Map::setBounds(const BoundOptions& options) {
impl->transform.setMaxZoom(*options.maxZoom);
if (impl->transform.getZoom() > *options.maxZoom) {
changeCamera = true;
cameraOptions.withZoom(*options.maxZoom);
cameraOptions.withZoom(options.maxZoom);
}
}
@@ -330,7 +330,7 @@ void Map::setBounds(const BoundOptions& options) {
impl->transform.setMaxPitch(*options.maxPitch);
if (impl->transform.getPitch() > impl->transform.getState().getMaxPitch()) {
changeCamera = true;
cameraOptions.withPitch(*options.maxPitch);
cameraOptions.withPitch(options.maxPitch);
}
}
@@ -338,7 +338,7 @@ void Map::setBounds(const BoundOptions& options) {
impl->transform.setMinPitch(*options.minPitch);
if (impl->transform.getPitch() < impl->transform.getState().getMinPitch()) {
changeCamera = true;
cameraOptions.withPitch(*options.minPitch);
cameraOptions.withPitch(options.minPitch);
}
}

View File

@@ -240,7 +240,6 @@ const BufferResource& Context::getEmptyBuffer() {
const BufferResource& Context::getTileVertexBuffer() {
if (!tileVertexBuffer) {
const auto vertices = RenderStaticData::tileVertices();
constexpr auto vertexSize = sizeof(decltype(vertices)::Vertex::a1);
tileVertexBuffer.emplace(createBuffer(vertices.data(),
vertices.bytes(),
gfx::BufferUsageType::StaticDraw,

View File

@@ -364,7 +364,6 @@ void Drawable::bindAttributes(RenderPass& renderPass) const noexcept {
assert(binding->vertexStride * impl->vertexCount <= getBufferSize(binding->vertexBufferResource));
renderPass.bindVertex(buffer->get(), /*offset=*/0, attributeIndex);
} else {
const auto* shaderMTL = static_cast<const ShaderProgram*>(shader.get());
auto& context = renderPass.getCommandEncoder().getContext();
renderPass.bindVertex(context.getEmptyBuffer(), /*offset=*/0, attributeIndex);
}
@@ -382,7 +381,6 @@ void Drawable::bindInstanceAttributes(RenderPass& renderPass) const noexcept {
if (buffer && buffer->get()) {
renderPass.bindVertex(buffer->get(), /*offset=*/0, attributeIndex);
} else {
const auto* shaderMTL = static_cast<const ShaderProgram*>(shader.get());
auto& context = renderPass.getCommandEncoder().getContext();
renderPass.bindVertex(context.getEmptyBuffer(), /*offset=*/0, attributeIndex);
}

View File

@@ -61,47 +61,23 @@ std::unique_ptr<gfx::Context> RendererBackend::createContext() {
PremultipliedImage RendererBackend::readFramebuffer(const Size& size) {
return PremultipliedImage(size);
// return getContext<mtl::Context>().readFramebuffer<PremultipliedImage>(size);
}
void RendererBackend::assumeFramebufferBinding(const mtl::FramebufferID fbo) {
/*getContext<mtl::Context>().bindFramebuffer.setCurrentValue(fbo);
if (fbo != ImplicitFramebufferBinding) {
assert(mtl::value::BindFramebuffer::Get() == getContext<mtl::Context>().bindFramebuffer.getCurrentValue());
}*/
}
void RendererBackend::assumeFramebufferBinding(const mtl::FramebufferID fbo) {}
void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) {
/*getContext<mtl::Context>().viewport.setCurrentValue({x, y, size});
assert(mtl::value::Viewport::Get() == getContext<mtl::Context>().viewport.getCurrentValue());*/
}
void RendererBackend::assumeViewport(int32_t x, int32_t y, const Size& size) {}
void RendererBackend::assumeScissorTest(bool enabled) {
/*getContext<mtl::Context>().scissorTest.setCurrentValue(enabled);
assert(mtl::value::ScissorTest::Get() == getContext<mtl::Context>().scissorTest.getCurrentValue());*/
}
void RendererBackend::assumeScissorTest(bool enabled) {}
bool RendererBackend::implicitFramebufferBound() {
return false;
// return getContext<mtl::Context>().bindFramebuffer.getCurrentValue() == ImplicitFramebufferBinding;
}
void RendererBackend::setFramebufferBinding(const mtl::FramebufferID fbo) {
/*getContext<mtl::Context>().bindFramebuffer = fbo;
if (fbo != ImplicitFramebufferBinding) {
assert(mtl::value::BindFramebuffer::Get() == getContext<mtl::Context>().bindFramebuffer.getCurrentValue());
}*/
}
void RendererBackend::setFramebufferBinding(const mtl::FramebufferID fbo) {}
void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) {
/*getContext<mtl::Context>().viewport = {x, y, size};
assert(mtl::value::Viewport::Get() == getContext<mtl::Context>().viewport.getCurrentValue());*/
}
void RendererBackend::setViewport(int32_t x, int32_t y, const Size& size) {}
void RendererBackend::setScissorTest(bool enabled) {
/*getContext<mtl::Context>().scissorTest = enabled;
assert(mtl::value::ScissorTest::Get() == getContext<mtl::Context>().scissorTest.getCurrentValue());*/
}
void RendererBackend::setScissorTest(bool enabled) {}
/// @brief Register a list of types with a shader registry instance
/// @tparam ...ShaderID Pack of BuiltIn:: shader IDs

View File

@@ -1,6 +1,5 @@
#include <mbgl/renderer/layer_group.hpp>
#include <mbgl/gfx/upload_pass.hpp>
#include <mbgl/gfx/drawable_tweaker.hpp>
#include <mbgl/renderer/layer_tweaker.hpp>
#include <mbgl/renderer/paint_parameters.hpp>

View File

@@ -9,7 +9,6 @@
#include <mbgl/util/containers.hpp>
#if MLN_RENDER_BACKEND_METAL
#include <mbgl/shaders/layer_ubo.hpp>
#include <mbgl/util/monotonic_timer.hpp>
#include <chrono>
#endif // MLN_RENDER_BACKEND_METAL

View File

@@ -16,10 +16,6 @@
#include <mbgl/util/convert.hpp>
#include <mbgl/util/std.hpp>
#if MLN_RENDER_BACKEND_METAL
#include <mbgl/shaders/mtl/fill.hpp>
#endif
namespace mbgl {
using namespace style;

View File

@@ -35,9 +35,10 @@ constexpr bool diff(Color actual, Color expected, float e = 1.0e-6) {
#if MLN_RENDER_BACKEND_METAL && !defined(NDEBUG)
template <typename Result>
std::optional<Result> LineLayerTweaker::gpuEvaluate(const LinePaintProperties::PossiblyEvaluated& evaluated,
const PaintParameters& parameters,
const std::size_t index) const {
std::optional<Result> LineLayerTweaker::gpuEvaluate(
[[maybe_unused]] const LinePaintProperties::PossiblyEvaluated& evaluated,
const PaintParameters& parameters,
const std::size_t index) const {
if (const auto& gpu = gpuExpressions[index]) {
const float effectiveZoom = (gpu->options & gfx::GPUOptions::IntegerZoom)
? parameters.state.getIntegerZoom()

View File

@@ -24,8 +24,10 @@ void RasterLayerTweaker::execute([[maybe_unused]] LayerGroupBase& layerGroup,
spin = util::deg2radf(spin);
const float s = std::sin(spin);
const float c = std::cos(spin);
std::array<float, 4> spin_weights = {
{(2 * c + 1) / 3, (-std::sqrt(3.0f) * s - c + 1) / 3, (std::sqrt(3.0f) * s - c + 1) / 3, 0}};
std::array<float, 4> spin_weights = {{(2 * c + 1) / 3,
(-std::numbers::sqrt3_v<float> * s - c + 1) / 3,
(std::numbers::sqrt3_v<float> * s - c + 1) / 3,
0}};
return spin_weights;
};
const auto saturationFactor = [](float saturation) -> float {

View File

@@ -1,8 +1,6 @@
#include <mbgl/renderer/layer_group.hpp>
#include <mbgl/gfx/upload_pass.hpp>
#include <mbgl/renderer/paint_parameters.hpp>
#include <mbgl/renderer/render_orchestrator.hpp>
#include <unordered_map>
#include <set>

View File

@@ -22,7 +22,7 @@ std::size_t hash(Args&&... args) noexcept {
namespace detail {
template <typename TIter>
using TIterVal = std::enable_if_t<std::is_integral<typename TIter::value_type>::value, typename TIter::value_type>;
using TIterVal = std::enable_if_t<std::is_integral_v<typename TIter::value_type>, typename TIter::value_type>;
} // namespace detail
template <typename T>

View File

@@ -32,15 +32,15 @@ namespace mbgl {
using mat3 = std::array<double, 9>;
constexpr inline vec3 vec3Cross(const vec3& a, const vec3& b) noexcept {
constexpr vec3 vec3Cross(const vec3& a, const vec3& b) noexcept {
return vec3{{a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]}};
}
constexpr inline double vec3Dot(const vec3& a, const vec3& b) noexcept {
constexpr double vec3Dot(const vec3& a, const vec3& b) noexcept {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
constexpr inline double vec3LengthSq(const vec3& a) noexcept {
constexpr double vec3LengthSq(const vec3& a) noexcept {
return vec3Dot(a, a);
}
@@ -48,7 +48,7 @@ inline double vec3Length(const vec3& a) noexcept {
return std::sqrt(vec3LengthSq(a));
}
constexpr inline vec3 vec3Scale(const vec3& a, double s) noexcept {
constexpr vec3 vec3Scale(const vec3& a, double s) noexcept {
return vec3{{a[0] * s, a[1] * s, a[2] * s}};
}
@@ -58,7 +58,7 @@ inline vec3 vec3Normalize(const vec3& a) noexcept {
return vec3Scale(a, 1.0 / length);
}
constexpr inline vec3 vec3Sub(const vec3& a, const vec3& b) noexcept {
constexpr vec3 vec3Sub(const vec3& a, const vec3& b) noexcept {
return vec3{{a[0] - b[0], a[1] - b[1], a[2] - b[2]}};
}

View File

@@ -8,7 +8,7 @@ using namespace mbgl;
using namespace std::numbers;
namespace mbgl {
constexpr inline bool operator==(const Anchor& rhs, const Anchor& lhs) {
constexpr bool operator==(const Anchor& rhs, const Anchor& lhs) {
return rhs.point == lhs.point && rhs.angle == lhs.angle && rhs.segment == lhs.segment;
}
} // namespace mbgl

14
vendor/unordered_dense.cmake vendored Normal file
View File

@@ -0,0 +1,14 @@
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25")
add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/unordered_dense SYSTEM)
else()
add_subdirectory(${PROJECT_SOURCE_DIR}/vendor/unordered_dense)
endif()
set_target_properties(
unordered_dense
PROPERTIES
INTERFACE_MAPBOX_NAME "unordered_dense"
INTERFACE_MAPBOX_URL "https://github.com/martinus/unordered_dense"
INTERFACE_MAPBOX_AUTHOR "Martin Leitner-Ankerl"
INTERFACE_MAPBOX_LICENSE ${PROJECT_SOURCE_DIR}/vendor/unordered_dense/LICENSE
)

7
vendor/vulkan.cmake vendored
View File

@@ -35,7 +35,12 @@ set(ENABLE_HLSL OFF)
set(ENABLE_GLSLANG_BINARIES OFF)
set(GLSLANG_TESTS_DEFAULT OFF)
set(ENABLE_PCH OFF)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glslang SYSTEM)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.25")
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glslang SYSTEM)
else()
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/glslang)
endif()
get_target_property(glslang_inc glslang INTERFACE_INCLUDE_DIRECTORIES)
set_target_properties(glslang PROPERTIES INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${glslang_inc})