Skip to content

Commit

Permalink
DataEquality, DataAssignment
Browse files Browse the repository at this point in the history
  • Loading branch information
morzhovets committed Jul 10, 2024
1 parent f3c6777 commit c5b9beb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
10 changes: 7 additions & 3 deletions include/momo/DataColumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ class DataEquality<Column>
const Item& mItem;
};

template<typename Column,
typename Item = typename internal::DataColumnItemSelector<Column>::Item>
DataEquality(Column, Item) -> DataEquality<Column>;
template<typename Column>
DataEquality(Column, typename internal::DataColumnItemSelector<Column>::Item)
-> DataEquality<Column>;

template<typename TColumn, typename TItemArg>
class DataAssignment
Expand Down Expand Up @@ -368,6 +368,10 @@ class DataAssignment
ItemArg&& mItemArg;
};

template<typename Column, typename ItemArg>
DataAssignment(Column, ItemArg&)
-> DataAssignment<Column, ItemArg&>;

template<typename... TVisitableItems>
struct DataStructDefault
{
Expand Down
8 changes: 4 additions & 4 deletions test/sources/SimpleDataSampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ namespace sample_data1
table.AddRow(strCol = "b", intCol = 1, dblCol = 0.5);
table.AddRow(intCol = 2, dblCol = 2.5); // strCol = ""

if (!table.TryAddRow(intCol = 1, dblCol = 3.5, strCol = "b"))
if (!table.TryAddRow(intCol = 2))
{
// not added because of unique index
// not added because of unique index (intCol == 2, strCol == "")
output << "!" << std::endl; // !
}

Expand Down Expand Up @@ -105,9 +105,9 @@ namespace sample_data2
table.TryAddRow(std::move(row)); // strCol = ""
}

if (!table.TryAddRow(table.NewRow({ .intCol = 1, .dblCol = 3.5, .strCol = "b" })))
if (!table.TryAddRow(momo::DataAssignment(&Struct::intCol, 2)))
{
// not added because of unique index
// not added because of unique index (intCol == 2, strCol == "")
output << "!" << std::endl; // !
}

Expand Down
5 changes: 3 additions & 2 deletions test/sources/SimpleDataTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,11 @@ class SimpleDataTester

for (size_t i = 0; i < count2; ++i)
{
int v = static_cast<int>(count + i);
if (native || i % 2 == 0)
table.InsertRow(count, momo::DataAssignment(intCol, static_cast<int>(count + i)));
table.InsertRow(count, momo::DataAssignment(intCol, v));
else if constexpr (!native)
table.TryInsertRow(count, intCol = static_cast<int>(count + i));
table.TryInsertRow(count, intCol = v);
}
assert(table.GetCount() == count + count2);

Expand Down

0 comments on commit c5b9beb

Please sign in to comment.