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
39 changes: 39 additions & 0 deletions CppLinq/cpplinq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <string>
#include <type_traits>
#include <vector>
#include <deque>
#// ----------------------------------------------------------------------------
#ifdef _MSC_VER
# pragma warning (push)
Expand Down Expand Up @@ -3296,6 +3297,39 @@ namespace cpplinq

// -------------------------------------------------------------------------

struct to_deque_builder : base_builder
{
typedef to_deque_builder this_type;

CPPLINQ_INLINEMETHOD explicit to_deque_builder() CPPLINQ_NOEXCEPT
{
}

CPPLINQ_INLINEMETHOD to_deque_builder(to_deque_builder const & v) CPPLINQ_NOEXCEPT
{
}

CPPLINQ_INLINEMETHOD to_deque_builder(to_deque_builder && v) CPPLINQ_NOEXCEPT
{
}

template<typename TRange>
CPPLINQ_METHOD std::deque<typename TRange::value_type> build(TRange range) const
{
std::deque<typename TRange::value_type> result;

while (range.next())
{
result.push_back(range.front());
}

return result;
}

};

// -------------------------------------------------------------------------

template<typename TKey, typename TValue>
struct lookup
{
Expand Down Expand Up @@ -5277,6 +5311,11 @@ namespace cpplinq
return detail::to_vector_builder (capacity);
}

CPPLINQ_INLINEMETHOD detail::to_deque_builder to_deque() CPPLINQ_NOEXCEPT
{
return detail::to_deque_builder();
}

CPPLINQ_INLINEMETHOD detail::to_list_builder to_list () CPPLINQ_NOEXCEPT
{
return detail::to_list_builder ();
Expand Down
22 changes: 22 additions & 0 deletions Test/CppLinqTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <string>
#include <sstream>
#include <vector>
#include <deque>
// ----------------------------------------------------------------------------------------------
#include <limits.h>
#include <stdio.h>
Expand Down Expand Up @@ -1368,6 +1369,27 @@ namespace
}
}

void test_to_deque ()
{
using namespace cpplinq;

TEST_PRELUDE ();

{
std::deque<int> to_deque_result = from (empty_vector) >> to_deque ();
TEST_ASSERT (0U, to_deque_result.size ());
}

{
std::deque<int> to_deque_result = from_array (ints) >> to_deque ();
TEST_ASSERT (count_of_ints, to_deque_result.size ());
for (auto index = 0U; index < to_deque_result.size (); ++index)
{
test_int_at (index, to_deque_result[index]);
}
}
}

void test_to_map ()
{
using namespace cpplinq;
Expand Down