mirror of
https://github.com/bolero-MURAKAMI/Sprout.git
synced 2025-07-12 14:54:10 +00:00
fix algorithm: copy for InputIterator
This commit is contained in:
parent
72fe72a623
commit
6ae41ef6de
4 changed files with 443 additions and 4 deletions
|
@ -101,6 +101,249 @@ namespace testspr {
|
|||
array<int, 10>{{0, 0, 3, 4, 5, 6, 7, 8, 0, 0}}
|
||||
));
|
||||
}
|
||||
|
||||
// [2 .. 8) の範囲をコピー
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_input(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 8),
|
||||
arr2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 10>{{3, 4, 5, 6, 7, 8, 0, 0, 0, 0}}
|
||||
));
|
||||
}
|
||||
// !!!
|
||||
// {
|
||||
// SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
// testspr::reduct_input(sprout::begin(arr1) + 2),
|
||||
// testspr::reduct_input(sprout::begin(arr1) + 8),
|
||||
// arr2
|
||||
// );
|
||||
// TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
// copied,
|
||||
// array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
// ));
|
||||
// }
|
||||
// [2 .. 8) の範囲をコピー
|
||||
// 出力範囲をオーバーする場合
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_input(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 8),
|
||||
arr3
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 4>{{3, 4, 5, 6}}
|
||||
));
|
||||
}
|
||||
// !!!
|
||||
// {
|
||||
// SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
// testspr::reduct_input(sprout::begin(arr1) + 2),
|
||||
// testspr::reduct_input(sprout::begin(arr1) + 8),
|
||||
// arr3
|
||||
// );
|
||||
// TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
// copied,
|
||||
// array<int, 4>{{3, 4, 5, 6}}
|
||||
// ));
|
||||
// }
|
||||
// [2 .. 8) の範囲をコピー
|
||||
// 出力範囲の切り出し
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_input(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_input(sprout::begin(arr1) + 8),
|
||||
sprout::sub(arr2, 2, 8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(copied),
|
||||
array<int, 10>{{0, 0, 3, 4, 5, 6, 7, 8, 0, 0}}
|
||||
));
|
||||
}
|
||||
// !!!
|
||||
// {
|
||||
// SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
// testspr::reduct_input(sprout::begin(arr1) + 2),
|
||||
// testspr::reduct_input(sprout::begin(arr1) + 8),
|
||||
// sprout::sub(arr2, 2, 8)
|
||||
// );
|
||||
// TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
// copied,
|
||||
// array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
// ));
|
||||
// TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
// sprout::get_internal(copied),
|
||||
// array<int, 10>{{0, 0, 3, 4, 5, 6, 7, 8, 0, 0}}
|
||||
// ));
|
||||
// }
|
||||
|
||||
// [2 .. 8) の範囲をコピー
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 8),
|
||||
arr2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 10>{{3, 4, 5, 6, 7, 8, 0, 0, 0, 0}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 8),
|
||||
arr2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
));
|
||||
}
|
||||
// [2 .. 8) の範囲をコピー
|
||||
// 出力範囲をオーバーする場合
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 8),
|
||||
arr3
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 4>{{3, 4, 5, 6}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 8),
|
||||
arr3
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 4>{{3, 4, 5, 6}}
|
||||
));
|
||||
}
|
||||
// [2 .. 8) の範囲をコピー
|
||||
// 出力範囲の切り出し
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 8),
|
||||
sprout::sub(arr2, 2, 8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(copied),
|
||||
array<int, 10>{{0, 0, 3, 4, 5, 6, 7, 8, 0, 0}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_forward(sprout::begin(arr1) + 8),
|
||||
sprout::sub(arr2, 2, 8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(copied),
|
||||
array<int, 10>{{0, 0, 3, 4, 5, 6, 7, 8, 0, 0}}
|
||||
));
|
||||
}
|
||||
|
||||
// [2 .. 8) の範囲をコピー
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 8),
|
||||
arr2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 10>{{3, 4, 5, 6, 7, 8, 0, 0, 0, 0}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 8),
|
||||
arr2
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
));
|
||||
}
|
||||
// [2 .. 8) の範囲をコピー
|
||||
// 出力範囲をオーバーする場合
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 8),
|
||||
arr3
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 4>{{3, 4, 5, 6}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 8),
|
||||
arr3
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 4>{{3, 4, 5, 6}}
|
||||
));
|
||||
}
|
||||
// [2 .. 8) の範囲をコピー
|
||||
// 出力範囲の切り出し
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::copy(
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 8),
|
||||
sprout::sub(arr2, 2, 8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(copied),
|
||||
array<int, 10>{{0, 0, 3, 4, 5, 6, 7, 8, 0, 0}}
|
||||
));
|
||||
}
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto copied = sprout::fit::copy(
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 2),
|
||||
testspr::reduct_random_access(sprout::begin(arr1) + 8),
|
||||
sprout::sub(arr2, 2, 8)
|
||||
);
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
copied,
|
||||
array<int, 6>{{3, 4, 5, 6, 7, 8}}
|
||||
));
|
||||
TESTSPR_BOTH_ASSERT(testspr::equal(
|
||||
sprout::get_internal(copied),
|
||||
array<int, 10>{{0, 0, 3, 4, 5, 6, 7, 8, 0, 0}}
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue