diff --git a/src/ifcparse/variantarray.h b/src/ifcparse/variantarray.h index 960921312a..6cd4053624 100644 --- a/src/ifcparse/variantarray.h +++ b/src/ifcparse/variantarray.h @@ -128,14 +128,14 @@ namespace impl { template class VariantArray { public: - using TypesTuple = impl::MapTypes_t; + using TypesTuple = ::impl::MapTypes_t; VariantArray(size_t size) : size_and_indices_(new uint8_t[size + 1]) , storage_(size ? new StorageType[size] : nullptr) { if (size) { - size_and_indices_[0] = (uint8_t) size; + size_and_indices_[0] = (uint8_t)size; memset(size_and_indices_ + 1, 0, sizeof(uint8_t) * size); for (size_t i = 0; i < size; ++i) { // type 0 needs to be default constructable @@ -172,17 +172,17 @@ public: template, VariantArray>>> void set(std::size_t index, T&& value) { using U = std::decay_t; - static_assert(impl::TypeIndex_v < sizeof...(Types), "Type not supported by variant"); + static_assert(::impl::TypeIndex_v < sizeof...(Types), "Type not supported by variant"); if (index >= size_and_indices_[0]) { throw std::out_of_range("Index out of range"); } destroy_at_index(index); - size_and_indices_[index + 1] = impl::TypeIndex_v; - using V = typename std::tuple_element, impl::MapTypes_t>::type; - // std::wcout << "setting " << index << " to " << typeid(V).name() << " (" << impl::TypeIndex_v << ")" << std::endl; - if constexpr (impl::is_unique_ptr::value) { + size_and_indices_[index + 1] = ::impl::TypeIndex_v; + using V = typename std::tuple_element<::impl::TypeIndex_v, ::impl::MapTypes_t>::type; + // std::wcout << "setting " << index << " to " << typeid(V).name() << " (" << ::impl::TypeIndex_v << ")" << std::endl; + if constexpr (::impl::is_unique_ptr::value) { new(&storage_[index]) V(new U(value)); } else { new(&storage_[index]) U(std::forward(value)); @@ -202,8 +202,8 @@ public: if (!has(index)) { throw std::bad_cast(); } - using V = typename std::tuple_element, impl::MapTypes_t>::type; - if constexpr (impl::is_unique_ptr::value) { + using V = typename std::tuple_element<::impl::TypeIndex_v, ::impl::MapTypes_t>::type; + if constexpr (::impl::is_unique_ptr::value) { return **reinterpret_cast(&storage_[index]); } else { return *reinterpret_cast(&storage_[index]); @@ -212,22 +212,22 @@ public: template bool has(std::size_t index) const { - return size_and_indices_[index + 1] == impl::TypeIndex::value; + return size_and_indices_[index + 1] == ::impl::TypeIndex::value; } template const T& get(std::size_t index) const { - if (size_and_indices_[index + 1] != impl::TypeIndex::value) { + if (size_and_indices_[index + 1] != ::impl::TypeIndex::value) { // @todo this IfcException is silly. Figure out what // to do, but at the moment it is specifically caught // in various places. throw IfcParse::IfcException( - "Type held at index " + std::to_string(index) + " is " + + "Type held at index " + std::to_string(index) + " is " + get_type_name(size_and_indices_[index + 1]) + " and not " + typeid(T).name() ); } - using V = typename std::tuple_element, impl::MapTypes_t>::type; - if constexpr (impl::is_unique_ptr::value) { + using V = typename std::tuple_element<::impl::TypeIndex_v, ::impl::MapTypes_t>::type; + if constexpr (::impl::is_unique_ptr::value) { return **reinterpret_cast(&storage_[index]); } else { return *reinterpret_cast(&storage_[index]); @@ -244,7 +244,7 @@ public: } private: - using StorageType = typename impl::make_union_from_tuple>::type; + using StorageType = typename ::impl::make_union_from_tuple<::impl::MapTypes_t>::type; uint8_t* size_and_indices_; StorageType* storage_; @@ -266,7 +266,7 @@ private: template void destroy_type_at_index(std::size_t index, std::integral_constant) { if (size_and_indices_[index + 1] == Index - 1) { - using T = typename std::tuple_element_t>; + using T = typename std::tuple_element_t>; if constexpr (!std::is_trivially_destructible::value) { reinterpret_cast(&storage_[index])->~T(); } @@ -281,8 +281,8 @@ private: template auto apply_visitor_impl(Visitor&& visitor, std::size_t idx, std::integral_constant) const { if (size_and_indices_[idx + 1] == Index - 1) { - using T = typename std::tuple_element_t>; - if constexpr (impl::is_unique_ptr::value) { + using T = typename std::tuple_element_t>; + if constexpr (::impl::is_unique_ptr::value) { return visitor(**reinterpret_cast(&storage_[idx])); } else { return visitor(*reinterpret_cast(&storage_[idx])); @@ -294,8 +294,8 @@ private: template auto apply_visitor_impl(Visitor&&, std::size_t, std::integral_constant) const { throw std::runtime_error("Invalid variant index"); - if constexpr (!std::is_void_v()(std::declval> &>()))>) { - return decltype(std::declval()(std::declval> &>())){}; + if constexpr (!std::is_void_v()(std::declval> &>()))>) { + return decltype(std::declval()(std::declval> &>())){}; } }