Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions source/include/gch/small_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,9 +1726,7 @@ namespace gch
|| std::contiguous_iterator<InputIt>
#endif
#ifdef GCH_STDLIB_INTEROP
|| std::is_same<InputIt, typename std::array<value_ty>::iterator>::value
|| std::is_same<InputIt, typename std::array<value_ty>::const_iterator>::value
|| (! std::is_same<value_ty, bool>
|| (! std::is_same<value_ty, bool>::value
Comment thread
gharveymn marked this conversation as resolved.
&& ( std::is_same<InputIt, typename std::vector<value_ty>::iterator>::value
|| std::is_same<InputIt, typename std::vector<value_ty>::const_iterator>::value)
)
Expand Down
7 changes: 7 additions & 0 deletions source/test/unit/member/assign/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ add_small_vector_unit_tests (
test-move.cpp
test-range.cpp
)

add_small_vector_unit_tests (
test-interop.cpp
NO_CONSTEXPR
COMPILE_DEFINITIONS
GCH_STDLIB_INTEROP
)
35 changes: 35 additions & 0 deletions source/test/unit/member/assign/test-interop.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/** test-interop.cpp
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#include "unit_test_common.hpp"

#include <array>
#include <valarray>
#include <vector>

GCH_SMALL_VECTOR_TEST_CONSTEXPR
int
test (void)
{
std::vector<int> src_vec { 1, 2, 3, 4 };
gch::small_vector<int, 2> from_vec (src_vec.begin (), src_vec.end ());
CHECK (from_vec.size () == src_vec.size ());
CHECK (std::equal (src_vec.begin (), src_vec.end (), from_vec.begin ()));

std::array<int, 4> src_arr { 5, 6, 7, 8 };
gch::small_vector<int, 2> from_arr;
from_arr.assign (src_arr.begin (), src_arr.end ());
CHECK (from_arr.size () == src_arr.size ());
CHECK (std::equal (src_arr.begin (), src_arr.end (), from_arr.begin ()));

const std::valarray<int> src_val { 9, 10, 11, 12 };
gch::small_vector<int, 2> from_val;
from_val.assign (std::begin (src_val), std::end (src_val));
CHECK (from_val.size () == src_val.size ());
CHECK (std::equal (std::begin (src_val), std::end (src_val), from_val.begin ()));
Comment on lines +28 to +32

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think std::valarray is the reason we can't test under constexpr here, but we should be able to test with std::vector and std::array. Perhaps we split them into files test-interop-array.cpp, test-interop-vector.cpp, test-interop-valarray.cpp, and only disable constexpr for test-interop-valarray.cpp?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'll give that a shot. Sorry it took so long to get back to this, life caught up with me.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries, life happens! If that doesn't work, could you rename this file to like test-std-interop.cpp or something? I'm not even nitpicking; it's because for some reason CLion has a bug or something and the targets don't show up with this file name (??? it's literally just when I have it as test-interop.cpp haha).


return 0;
}