Skip to content

Commit

Permalink
minor bugfixes + refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Aug 27, 2023
1 parent 7730f33 commit 1d86b36
Show file tree
Hide file tree
Showing 12 changed files with 1,092 additions and 1,233 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## v0.7.0

- Fixed rvalue row corruption bug on MSVC ([info](https://developercommunity.visualstudio.com/t/C:-Corrupt-references-when-creating-a/10446877))
- Fuxed some SFINAE issues
- Added `Cols...` selector template parameter to `at()`, `front()` and `back()`
- Added `structs.mixins`
- Added copy-based fallbacks for `unordered_erase()`, `insert()`, `emplace()` and `swap_columns()` (previously they required movability)
Expand Down
4 changes: 2 additions & 2 deletions docs/poxy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extra_files = [
'images/author.jpg',
]
stylesheets = ['pages.css']
navbar = ['schema', 'pages', 'namespaces', 'classes']
navbar = ['pages', 'namespaces', 'classes']

[warnings]
enabled = true
Expand All @@ -38,7 +38,7 @@ paths = [
'pages',
]
patterns = ['*.hpp', '*.dox', '*.md']
strip_paths = ['../src/soagen/hpp', '../examples']
strip_paths = ['../src/soagen/hpp', '../examples', 'pages']


# [examples]
Expand Down
325 changes: 159 additions & 166 deletions examples/entities.hpp

Large diffs are not rendered by default.

824 changes: 388 additions & 436 deletions examples/shapes.hpp

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/soagen/header_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ def write(self, o: Writer):
#if defined(DOXYGEN) || defined(__DOXYGEN) || defined(__DOXYGEN__) \
|| defined(__doxygen__) || defined(__POXY__) || defined(__poxy__)
#ifndef SOAGEN_CONSTRAINED_TEMPLATE
#define SOAGEN_CONSTRAINED_TEMPLATE(cond, ...) template <__VA_ARGS__>
#endif
#ifndef SOAGEN_DOXYGEN
#define SOAGEN_DOXYGEN 1
#endif
Expand Down
16 changes: 8 additions & 8 deletions src/soagen/hpp/iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,14 @@ namespace soagen
return iterator<T, Cols...>{ static_cast<const base&>(*this) };
}

SOAGEN_PURE_INLINE_GETTER
explicit constexpr operator size_type() const noexcept
{
SOAGEN_ASSUME(base::offset >= 0);

return static_cast<size_type>(base::offset);
}

/// @endcond

/// @brief Converts this iterator to it's underlying #difference_type value.
Expand All @@ -346,14 +354,6 @@ namespace soagen
return base::offset;
}

SOAGEN_PURE_INLINE_GETTER
explicit constexpr operator size_type() const noexcept
{
SOAGEN_ASSUME(base::offset >= 0);

return static_cast<size_type>(base::offset);
}

/// @}
};

Expand Down
141 changes: 54 additions & 87 deletions src/soagen/hpp/single/soagen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ SOAGEN_ENABLE_WARNINGS;
#endif

#if !defined(__POXY__) && !defined(POXY_IMPLEMENTATION_DETAIL)
#define ...) __VA_ARGS__
#define POXY_IMPLEMENTATION_DETAIL(...) __VA_ARGS__
#endif

//******** generated/functions.hpp ***********************************************************************************
Expand Down Expand Up @@ -1070,7 +1070,7 @@ namespace soagen

#elif SOAGEN_CLANG >= 9 || SOAGEN_GCC >= 9 || SOAGEN_MSVC >= 1925 || SOAGEN_HAS_BUILTIN(is_constant_evaluated)

return __builtin_is_constant_evaluated(;
return __builtin_is_constant_evaluated();

#elif defined(__cpp_lib_is_constant_evaluated) && __cpp_lib_is_constant_evaluated >= 201811

Expand Down Expand Up @@ -4702,8 +4702,7 @@ namespace soagen::detail
}
catch (...)
{
for (; i-- > start;)
destruct_row(columns, i);
destruct_rows(columns, start, i - start);
throw;
}
}
Expand Down Expand Up @@ -4775,7 +4774,6 @@ namespace soagen::detail
{
if (constructed_columns)
destruct_row(columns, index, 0u, constructed_columns - 1u);

throw;
}
}
Expand Down Expand Up @@ -4824,7 +4822,6 @@ namespace soagen::detail
{
if (constructed_columns)
destruct_row(dest, dest_index, 0u, constructed_columns - 1u);

throw;
}
}
Expand All @@ -4846,26 +4843,11 @@ namespace soagen::detail
{
memmove(dest, dest_start, source, source_start, count);
}
else if constexpr (all_nothrow_move_constructible)
{
if (&dest == &source && dest_start > source_start)
{
for (size_t i = count; i-- > 0u;)
move_construct_row(dest, dest_start + i, source, source_start + i);
}
else
{
for (size_t i = 0; i < count; i++)
move_construct_row(dest, dest_start + i, source, source_start + i);
}
}
else
{
// machinery to provide strong-exception guarantee
[[maybe_unused]] size_t i = 0;

size_t i = 0;

try
const auto constructor = [&]() noexcept(all_nothrow_move_constructible)
{
if (&dest == &source && dest_start > source_start)
{
Expand All @@ -4877,20 +4859,25 @@ namespace soagen::detail
for (; i < count; i++)
move_construct_row(dest, dest_start + i, source, source_start + i);
}
};

if constexpr (all_nothrow_move_constructible)
{
constructor();
}
catch (...)
else
{
if (&dest == &source && dest_start > source_start)
// machinery to provide strong-exception guarantee

try
{
for (; i < count; i++)
destruct_row(dest, dest_start + i);
constructor();
}
else
catch (...)
{
for (; i-- > 0u;)
destruct_row(dest, dest_start + i);
destruct_rows(dest, dest_start, i - dest_start);
throw;
}
throw;
}
}
}
Expand Down Expand Up @@ -4959,26 +4946,11 @@ namespace soagen::detail
{
memmove(dest, dest_start, source, source_start, count);
}
else if constexpr (all_nothrow_copy_constructible)
{
if (&dest == &source && dest_start > source_start)
{
for (size_t i = count; i-- > 0u;)
copy_construct_row(dest, dest_start + i, source, source_start + i);
}
else
{
for (size_t i = 0; i < count; i++)
copy_construct_row(dest, dest_start + i, source, source_start + i);
}
}
else
{
// machinery to provide strong-exception guarantee

size_t i = 0;
[[maybe_unused]] size_t i = 0;

try
const auto constructor = [&]() noexcept(all_nothrow_copy_constructible)
{
if (&dest == &source && dest_start > source_start)
{
Expand All @@ -4990,20 +4962,25 @@ namespace soagen::detail
for (; i < count; i++)
copy_construct_row(dest, dest_start + i, source, source_start + i);
}
};

if constexpr (all_nothrow_copy_constructible)
{
constructor();
}
catch (...)
else
{
if (&dest == &source && dest_start > source_start)
// machinery to provide strong-exception guarantee

try
{
for (; i < count; i++)
destruct_row(dest, dest_start + i);
constructor();
}
else
catch (...)
{
for (; i-- > 0u;)
destruct_row(dest, dest_start + i);
destruct_rows(dest, dest_start, i - dest_start);
throw;
}
throw;
}
}
}
Expand Down Expand Up @@ -5072,26 +5049,11 @@ namespace soagen::detail
{
memmove(dest, dest_start, source, source_start, count);
}
else if constexpr (all_nothrow_move_or_copy_constructible)
{
if (&dest == &source && dest_start > source_start)
{
for (size_t i = count; i-- > 0u;)
move_or_copy_construct_row(dest, dest_start + i, source, source_start + i);
}
else
{
for (size_t i = 0; i < count; i++)
move_or_copy_construct_row(dest, dest_start + i, source, source_start + i);
}
}
else
{
// machinery to provide strong-exception guarantee

size_t i = 0;
[[maybe_unused]] size_t i = 0;

try
const auto constructor = [&]() noexcept(all_nothrow_move_or_copy_constructible)
{
if (&dest == &source && dest_start > source_start)
{
Expand All @@ -5103,20 +5065,25 @@ namespace soagen::detail
for (; i < count; i++)
move_or_copy_construct_row(dest, dest_start + i, source, source_start + i);
}
};

if constexpr (all_nothrow_move_or_copy_constructible)
{
constructor();
}
catch (...)
else
{
if (&dest == &source && dest_start > source_start)
// machinery to provide strong-exception guarantee

try
{
for (; i < count; i++)
move_or_copy_construct_row(dest, dest_start + i);
constructor();
}
else
catch (...)
{
for (; i-- > 0u;)
move_or_copy_construct_row(dest, dest_start + i);
destruct_rows(dest, dest_start, i - dest_start);
throw;
}
throw;
}
}
}
Expand Down Expand Up @@ -5695,19 +5662,19 @@ namespace soagen
return iterator<T, Cols...>{ static_cast<const base&>(*this) };
}

SOAGEN_PURE_INLINE_GETTER
explicit constexpr operator difference_type() const noexcept
{
return base::offset;
}

SOAGEN_PURE_INLINE_GETTER
explicit constexpr operator size_type() const noexcept
{
SOAGEN_ASSUME(base::offset >= 0);

return static_cast<size_type>(base::offset);
}

SOAGEN_PURE_INLINE_GETTER
explicit constexpr operator difference_type() const noexcept
{
return base::offset;
}
};

template <typename Soa, size_t... Columns>
Expand Down
Loading

0 comments on commit 1d86b36

Please sign in to comment.