Skip to content

Commit

Permalink
fix SFINAE bug
Browse files Browse the repository at this point in the history
  • Loading branch information
marzer committed Jul 26, 2023
1 parent 8c85fee commit 4356255
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 81 deletions.
112 changes: 56 additions & 56 deletions examples/shapes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,15 +673,15 @@ namespace soagen::examples
/// @brief Adds a new row at the end of the table (rvalue overload).
SOAGEN_HIDDEN(template <bool sfinae = table_traits::rvalue_type_list_is_distinct>)
SOAGEN_CPP20_CONSTEXPR
SOAGEN_ENABLE_IF_T(boxes&, sfinae) push_back(column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type extents_x = 0.5f,
column_traits<4>::rvalue_type extents_y = 0.5f,
column_traits<5>::rvalue_type extents_z = 0.5f,
column_traits<6>::rvalue_type mass = default_mass) //
boxes& push_back(SOAGEN_ENABLE_IF_T(column_traits<0>::rvalue_type, sfinae) center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type extents_x = 0.5f,
column_traits<4>::rvalue_type extents_y = 0.5f,
column_traits<5>::rvalue_type extents_z = 0.5f,
column_traits<6>::rvalue_type mass = default_mass) //
noexcept(table_traits::rvalue_push_back_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct) //
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct) //
{
table_.emplace_back(static_cast<column_traits<0>::rvalue_forward_type>(center_x),
static_cast<column_traits<1>::rvalue_forward_type>(center_y),
Expand Down Expand Up @@ -840,14 +840,14 @@ namespace soagen::examples
&& table_traits::all_move_assignable)>
)
SOAGEN_CPP20_CONSTEXPR
SOAGEN_ENABLE_IF_T(boxes&, sfinae) insert(size_type index_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type extents_x = 0.5f,
column_traits<4>::rvalue_type extents_y = 0.5f,
column_traits<5>::rvalue_type extents_z = 0.5f,
column_traits<6>::rvalue_type mass = default_mass) //
boxes& insert(SOAGEN_ENABLE_IF_T(size_type, sfinae) index_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type extents_x = 0.5f,
column_traits<4>::rvalue_type extents_y = 0.5f,
column_traits<5>::rvalue_type extents_z = 0.5f,
column_traits<6>::rvalue_type mass = default_mass) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand All @@ -871,14 +871,14 @@ namespace soagen::examples
&& table_traits::all_move_assignable)>
)
SOAGEN_CPP20_CONSTEXPR
SOAGEN_ENABLE_IF_T(iterator, sfinae) insert(iterator iter_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type extents_x = 0.5f,
column_traits<4>::rvalue_type extents_y = 0.5f,
column_traits<5>::rvalue_type extents_z = 0.5f,
column_traits<6>::rvalue_type mass = default_mass) //
iterator insert(SOAGEN_ENABLE_IF_T(iterator, sfinae) iter_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type extents_x = 0.5f,
column_traits<4>::rvalue_type extents_y = 0.5f,
column_traits<5>::rvalue_type extents_z = 0.5f,
column_traits<6>::rvalue_type mass = default_mass) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand All @@ -902,14 +902,14 @@ namespace soagen::examples
&& table_traits::all_move_assignable)>
)
SOAGEN_CPP20_CONSTEXPR
SOAGEN_ENABLE_IF_T(const_iterator, sfinae) insert(const_iterator iter_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type extents_x = 0.5f,
column_traits<4>::rvalue_type extents_y = 0.5f,
column_traits<5>::rvalue_type extents_z = 0.5f,
column_traits<6>::rvalue_type mass = default_mass) //
const_iterator insert(SOAGEN_ENABLE_IF_T(const_iterator, sfinae) iter_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type extents_x = 0.5f,
column_traits<4>::rvalue_type extents_y = 0.5f,
column_traits<5>::rvalue_type extents_z = 0.5f,
column_traits<6>::rvalue_type mass = default_mass) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand Down Expand Up @@ -2007,13 +2007,13 @@ namespace soagen::examples
/// @brief Adds a new row at the end of the table (rvalue overload).
SOAGEN_HIDDEN(template <bool sfinae = table_traits::rvalue_type_list_is_distinct>)
SOAGEN_CPP20_CONSTEXPR
SOAGEN_ENABLE_IF_T(spheres&, sfinae) push_back(column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type radius = 0.5f,
column_traits<4>::rvalue_type mass = default_mass) //
spheres& push_back(SOAGEN_ENABLE_IF_T(column_traits<0>::rvalue_type, sfinae) center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type radius = 0.5f,
column_traits<4>::rvalue_type mass = default_mass) //
noexcept(table_traits::rvalue_push_back_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct) //
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct) //
{
table_.emplace_back(static_cast<column_traits<0>::rvalue_forward_type>(center_x),
static_cast<column_traits<1>::rvalue_forward_type>(center_y),
Expand Down Expand Up @@ -2146,12 +2146,12 @@ namespace soagen::examples
&& table_traits::all_move_assignable)>
)
SOAGEN_CPP20_CONSTEXPR
SOAGEN_ENABLE_IF_T(spheres&, sfinae) insert(size_type index_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type radius = 0.5f,
column_traits<4>::rvalue_type mass = default_mass) //
spheres& insert(SOAGEN_ENABLE_IF_T(size_type, sfinae) index_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type radius = 0.5f,
column_traits<4>::rvalue_type mass = default_mass) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand All @@ -2173,12 +2173,12 @@ namespace soagen::examples
&& table_traits::all_move_assignable)>
)
SOAGEN_CPP20_CONSTEXPR
SOAGEN_ENABLE_IF_T(iterator, sfinae) insert(iterator iter_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type radius = 0.5f,
column_traits<4>::rvalue_type mass = default_mass) //
iterator insert(SOAGEN_ENABLE_IF_T(iterator, sfinae) iter_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type radius = 0.5f,
column_traits<4>::rvalue_type mass = default_mass) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand All @@ -2200,12 +2200,12 @@ namespace soagen::examples
&& table_traits::all_move_assignable)>
)
SOAGEN_CPP20_CONSTEXPR
SOAGEN_ENABLE_IF_T(const_iterator, sfinae) insert(const_iterator iter_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type radius = 0.5f,
column_traits<4>::rvalue_type mass = default_mass) //
const_iterator insert(SOAGEN_ENABLE_IF_T(const_iterator, sfinae) iter_,
column_traits<0>::rvalue_type center_x,
column_traits<1>::rvalue_type center_y,
column_traits<2>::rvalue_type center_z,
column_traits<3>::rvalue_type radius = 0.5f,
column_traits<4>::rvalue_type mass = default_mass) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand Down
2 changes: 1 addition & 1 deletion src/soagen/struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ def doxygen(s: str) -> str:

sig_hash += '##'.join(types)
if not sfinae_sig_hash or sfinae_sig_hash != sig_hash:
sfinae_variant = -1
sfinae_variant = 0 if rvalue_overload else -1
sfinae_sig_hash = sig_hash

sfinae = []
Expand Down
48 changes: 24 additions & 24 deletions tests/employees.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,13 +358,13 @@ namespace tests

template <bool sfinae = table_traits::rvalue_type_list_is_distinct>
SOAGEN_CPP20_CONSTEXPR
std::enable_if_t<sfinae, employees&> push_back(column_traits<0>::rvalue_type name,
column_traits<1>::rvalue_type id,
column_traits<2>::rvalue_type date_of_birth,
column_traits<3>::rvalue_type salary,
column_traits<4>::rvalue_type tag = nullptr) //
employees& push_back(std::enable_if_t<sfinae, column_traits<0>::rvalue_type> name,
column_traits<1>::rvalue_type id,
column_traits<2>::rvalue_type date_of_birth,
column_traits<3>::rvalue_type salary,
column_traits<4>::rvalue_type tag = nullptr) //
noexcept(table_traits::rvalue_push_back_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct) //
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct) //
{
table_.emplace_back(static_cast<column_traits<0>::rvalue_forward_type>(name),
static_cast<column_traits<1>::rvalue_forward_type>(id),
Expand Down Expand Up @@ -470,12 +470,12 @@ namespace tests
template <bool sfinae = (table_traits::rvalue_type_list_is_distinct && table_traits::all_move_constructible
&& table_traits::all_move_assignable)>
SOAGEN_CPP20_CONSTEXPR
std::enable_if_t<sfinae, employees&> insert(size_type index_,
column_traits<0>::rvalue_type name,
column_traits<1>::rvalue_type id,
column_traits<2>::rvalue_type date_of_birth,
column_traits<3>::rvalue_type salary,
column_traits<4>::rvalue_type tag = nullptr) //
employees& insert(std::enable_if_t<sfinae, size_type> index_,
column_traits<0>::rvalue_type name,
column_traits<1>::rvalue_type id,
column_traits<2>::rvalue_type date_of_birth,
column_traits<3>::rvalue_type salary,
column_traits<4>::rvalue_type tag = nullptr) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand All @@ -492,12 +492,12 @@ namespace tests
template <bool sfinae = (table_traits::rvalue_type_list_is_distinct && table_traits::all_move_constructible
&& table_traits::all_move_assignable)>
SOAGEN_CPP20_CONSTEXPR
std::enable_if_t<sfinae, iterator> insert(iterator iter_,
column_traits<0>::rvalue_type name,
column_traits<1>::rvalue_type id,
column_traits<2>::rvalue_type date_of_birth,
column_traits<3>::rvalue_type salary,
column_traits<4>::rvalue_type tag = nullptr) //
iterator insert(std::enable_if_t<sfinae, iterator> iter_,
column_traits<0>::rvalue_type name,
column_traits<1>::rvalue_type id,
column_traits<2>::rvalue_type date_of_birth,
column_traits<3>::rvalue_type salary,
column_traits<4>::rvalue_type tag = nullptr) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand All @@ -514,12 +514,12 @@ namespace tests
template <bool sfinae = (table_traits::rvalue_type_list_is_distinct && table_traits::all_move_constructible
&& table_traits::all_move_assignable)>
SOAGEN_CPP20_CONSTEXPR
std::enable_if_t<sfinae, const_iterator> insert(const_iterator iter_,
column_traits<0>::rvalue_type name,
column_traits<1>::rvalue_type id,
column_traits<2>::rvalue_type date_of_birth,
column_traits<3>::rvalue_type salary,
column_traits<4>::rvalue_type tag = nullptr) //
const_iterator insert(std::enable_if_t<sfinae, const_iterator> iter_,
column_traits<0>::rvalue_type name,
column_traits<1>::rvalue_type id,
column_traits<2>::rvalue_type date_of_birth,
column_traits<3>::rvalue_type salary,
column_traits<4>::rvalue_type tag = nullptr) //
noexcept(table_traits::rvalue_insert_is_nothrow<table_type&>)
SOAGEN_REQUIRES(table_traits::rvalue_type_list_is_distinct&& table_traits::all_move_constructible&&
table_traits::all_move_assignable) //
Expand Down

0 comments on commit 4356255

Please sign in to comment.