mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2024-11-12 21:09:01 +00:00
add array_sub template
This commit is contained in:
parent
0f210dee5f
commit
2ebfc158b9
3 changed files with 35 additions and 5 deletions
|
@ -15,9 +15,6 @@
|
|||
#include <sprout/string.hpp>
|
||||
#include <sprout/algorithm.hpp>
|
||||
|
||||
template<typename T, std::size_t N>
|
||||
using subbed_array = sprout::sub_array<sprout::array<T, N> >;
|
||||
|
||||
template<typename Char>
|
||||
struct csv_parser_settings {
|
||||
public:
|
||||
|
@ -45,10 +42,10 @@ public:
|
|||
};
|
||||
|
||||
template<std::size_t N, std::size_t L, typename String, typename ResultString = String>
|
||||
constexpr subbed_array<subbed_array<ResultString, N>, L>
|
||||
constexpr sprout::array_sub_t<sprout::array_sub_t<ResultString, N>, L>
|
||||
parse_csv(String const& src, csv_parser_settings<typename String::value_type> settings = csv_parser_settings<typename String::value_type>()) {
|
||||
typedef typename String::value_type value_type;
|
||||
subbed_array<subbed_array<ResultString, N>, L> result = {};
|
||||
sprout::array_sub_t<sprout::array_sub_t<ResultString, N>, L> result = {};
|
||||
result.window(0, 1);
|
||||
result.back().window(0, 0);
|
||||
auto delimiters = sprout::make_string(settings.delimiter(), value_type('\r'), value_type('\n'));
|
||||
|
|
|
@ -18,5 +18,6 @@
|
|||
#include <sprout/sub_array/sub_window.hpp>
|
||||
#include <sprout/sub_array/sub_offset.hpp>
|
||||
#include <sprout/sub_array/type_traits.hpp>
|
||||
#include <sprout/sub_array/array_sub.hpp>
|
||||
|
||||
#endif // #ifndef SPROUT_SUB_ARRAY_HPP
|
||||
|
|
32
sprout/sub_array/array_sub.hpp
Normal file
32
sprout/sub_array/array_sub.hpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*=============================================================================
|
||||
Copyright (c) 2011-2016 Bolero MURAKAMI
|
||||
https://github.com/bolero-MURAKAMI/Sprout
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
=============================================================================*/
|
||||
#ifndef SPROUT_SUB_ARRAY_ARRAY_SUB_HPP
|
||||
#define SPROUT_SUB_ARRAY_ARRAY_SUB_HPP
|
||||
|
||||
#include <sprout/config.hpp>
|
||||
#include <sprout/workaround/std/cstddef.hpp>
|
||||
#include <sprout/array/array.hpp>
|
||||
#include <sprout/sub_array/sub_array.hpp>
|
||||
#include <sprout/type_traits/identity.hpp>
|
||||
|
||||
namespace sprout {
|
||||
//
|
||||
// array_sub
|
||||
//
|
||||
template<typename T, std::size_t N>
|
||||
struct array_sub
|
||||
: public sprout::identity<sprout::sub_array<sprout::array<T, N> > >
|
||||
{};
|
||||
|
||||
#if SPROUT_USE_TEMPLATE_ALIASES
|
||||
template<typename T, std::size_t N>
|
||||
using array_sub_t = typename sprout::array_sub<T, N>::type;
|
||||
#endif // #if SPROUT_USE_TEMPLATE_ALIASES
|
||||
} // namespace sprout
|
||||
|
||||
#endif // #ifndef SPROUT_SUB_ARRAY_ARRAY_SUB_HPP
|
Loading…
Reference in a new issue