Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex-PLACET committed Sep 4, 2024
1 parent 9e73425 commit 6af9ffa
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
12 changes: 3 additions & 9 deletions include/sparrow/arrow_array_schema_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <cstdint>
#include <variant>
#include <vector>
Expand All @@ -23,6 +25,7 @@
#include "sparrow/buffer/buffer_view.hpp"
#include "sparrow/utils/contracts.hpp"
#include "sparrow/utils/mp_utils.hpp"
#include "sparrow/utils/variant_visitor.hpp"

namespace sparrow
{
Expand Down Expand Up @@ -269,15 +272,6 @@ namespace sparrow
return array().private_data;
}

template <class... Ts>
struct overloaded : Ts...
{
using Ts::operator()...;
};
// Although not required in C++20, clang needs it to build the code below
template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;

template <typename T>
[[nodiscard]] T& get_value_reference_of_variant(auto& var)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include "sparrow/array/data_type.hpp"
#include "sparrow/c_interface.hpp"
Expand Down
16 changes: 5 additions & 11 deletions include/sparrow/buffer/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

#pragma once

#include <cstdint>
#include <memory>
#include <memory_resource>
#include <type_traits>
#include <typeindex>
#include <variant>

#include "sparrow/utils/variant_visitor.hpp"


namespace sparrow
{
/*
Expand Down Expand Up @@ -149,15 +151,6 @@ namespace sparrow
return std::forward<A>(alloc);
}

template <class... Ts>
struct overloaded : Ts...
{
using Ts::operator()...;
};
// Although not required in C++20, clang needs it to build the code below
template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;

storage_type copy_storage(const storage_type& rhs) const
{
return std::visit(
Expand Down Expand Up @@ -236,7 +229,8 @@ namespace sparrow
# endif
# endif
#endif
void any_allocator<T>::deallocate(T* p, std::size_t n)
void
any_allocator<T>::deallocate(T* p, std::size_t n)
{
return visit_storage(
[n, p](auto& allocator)
Expand Down
27 changes: 27 additions & 0 deletions include/sparrow/utils/variant_visitor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2024 Man Group Operations Limited
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

namespace sparrow
{
template <class... Ts>
struct overloaded : Ts...
{
using Ts::operator()...;
};
// Although not required in C++20, clang needs it to build the code below
template <class... Ts>
overloaded(Ts...) -> overloaded<Ts...>;
}

0 comments on commit 6af9ffa

Please sign in to comment.