diff --git a/include/sparrow/arrow_array_schema_proxy.hpp b/include/sparrow/arrow_array_schema_proxy.hpp index d6d3c7c60..c56aa0665 100644 --- a/include/sparrow/arrow_array_schema_proxy.hpp +++ b/include/sparrow/arrow_array_schema_proxy.hpp @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#pragma once + #include #include #include @@ -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 { @@ -269,15 +272,6 @@ namespace sparrow return array().private_data; } - template - struct overloaded : Ts... - { - using Ts::operator()...; - }; - // Although not required in C++20, clang needs it to build the code below - template - overloaded(Ts...) -> overloaded; - template [[nodiscard]] T& get_value_reference_of_variant(auto& var) { diff --git a/include/sparrow/arrow_interface/arrow_array_schema_proxy_utils.hpp b/include/sparrow/arrow_interface/arrow_array_schema_proxy_utils.hpp index bf77312f5..b2168ea4e 100644 --- a/include/sparrow/arrow_interface/arrow_array_schema_proxy_utils.hpp +++ b/include/sparrow/arrow_interface/arrow_array_schema_proxy_utils.hpp @@ -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" diff --git a/include/sparrow/buffer/allocator.hpp b/include/sparrow/buffer/allocator.hpp index d1e68580e..a0dc13a47 100644 --- a/include/sparrow/buffer/allocator.hpp +++ b/include/sparrow/buffer/allocator.hpp @@ -14,13 +14,15 @@ #pragma once -#include #include #include #include #include #include +#include "sparrow/utils/variant_visitor.hpp" + + namespace sparrow { /* @@ -149,15 +151,6 @@ namespace sparrow return std::forward(alloc); } - template - struct overloaded : Ts... - { - using Ts::operator()...; - }; - // Although not required in C++20, clang needs it to build the code below - template - overloaded(Ts...) -> overloaded; - storage_type copy_storage(const storage_type& rhs) const { return std::visit( @@ -236,7 +229,8 @@ namespace sparrow # endif # endif #endif - void any_allocator::deallocate(T* p, std::size_t n) + void + any_allocator::deallocate(T* p, std::size_t n) { return visit_storage( [n, p](auto& allocator) diff --git a/include/sparrow/utils/variant_visitor.hpp b/include/sparrow/utils/variant_visitor.hpp new file mode 100644 index 000000000..6da68db66 --- /dev/null +++ b/include/sparrow/utils/variant_visitor.hpp @@ -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 + struct overloaded : Ts... + { + using Ts::operator()...; + }; + // Although not required in C++20, clang needs it to build the code below + template + overloaded(Ts...) -> overloaded; +} \ No newline at end of file