Browse Source
- Replace struct-based hasher/eq_compare with inline method definitions - Introduce get_quadrics_character() for unified quadric surface identity - Add get_plane_character() for plane surface identity - Replace std::variant pair arrays with heter_array in data_center - Add heter_array utility containerV2-integral
12 changed files with 178 additions and 164 deletions
@ -0,0 +1,43 @@ |
|||||
|
#pragma once |
||||
|
|
||||
|
#include <array> |
||||
|
#include <variant> |
||||
|
|
||||
|
template <typename... Ts> |
||||
|
struct heter_array { |
||||
|
heter_array() : data(this->default_ctor_impl(std::make_index_sequence<N>{})) {} |
||||
|
|
||||
|
~heter_array() = default; |
||||
|
|
||||
|
heter_array(const heter_array&) = default; |
||||
|
heter_array(heter_array&&) = default; |
||||
|
heter_array& operator=(const heter_array&) = default; |
||||
|
heter_array& operator=(heter_array&&) = default; |
||||
|
|
||||
|
auto& operator[](size_t i) { return data[i]; } |
||||
|
|
||||
|
const auto& operator[](size_t i) const { return data[i]; } |
||||
|
|
||||
|
template <typename F> |
||||
|
decltype(auto) visit(size_t i, F&& f) |
||||
|
{ |
||||
|
return std::visit(std::forward<F>(f), data[i]); |
||||
|
} |
||||
|
|
||||
|
template <typename F> |
||||
|
decltype(auto) visit(size_t i, F&& f) const |
||||
|
{ |
||||
|
return std::visit(std::forward<F>(f), data[i]); |
||||
|
} |
||||
|
|
||||
|
protected: |
||||
|
template <size_t... Is> |
||||
|
static auto default_ctor_impl(std::index_sequence<Is...>) |
||||
|
{ |
||||
|
return std::array<heter_type, N>{heter_type{std::in_place_index<Is>}...}; |
||||
|
} |
||||
|
|
||||
|
using heter_type = std::variant<Ts...>; |
||||
|
static constexpr size_t N = sizeof...(Ts); |
||||
|
std::array<heter_type, N> data{}; |
||||
|
}; |
||||
Loading…
Reference in new issue