summaryrefslogtreecommitdiff
path: root/boost/spirit/home/x3/support/traits/container_traits.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/spirit/home/x3/support/traits/container_traits.hpp')
-rw-r--r--boost/spirit/home/x3/support/traits/container_traits.hpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/boost/spirit/home/x3/support/traits/container_traits.hpp b/boost/spirit/home/x3/support/traits/container_traits.hpp
index c382b7bfaa..ed9213b68c 100644
--- a/boost/spirit/home/x3/support/traits/container_traits.hpp
+++ b/boost/spirit/home/x3/support/traits/container_traits.hpp
@@ -9,10 +9,6 @@
#if !defined(BOOST_SPIRIT_X3_CONTAINER_FEBRUARY_06_2007_1001AM)
#define BOOST_SPIRIT_X3_CONTAINER_FEBRUARY_06_2007_1001AM
-#if defined(_MSC_VER)
-#pragma once
-#endif
-
#include <boost/fusion/support/category_of.hpp>
#include <boost/spirit/home/x3/support/unused.hpp>
#include <boost/detail/iterator.hpp>
@@ -20,8 +16,12 @@
#include <boost/mpl/has_xxx.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/identity.hpp>
+
#include <vector>
+#include <map>
#include <string>
+#include <iterator>
+#include <algorithm>
namespace boost { namespace spirit { namespace x3 { namespace traits
{
@@ -112,10 +112,22 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
template <typename Container, typename Enable = void>
struct push_back_container
{
+ template <typename Key, typename Value, typename Compare, typename Allocator, typename T>
+ static void push_back(std::map<Key, Value, Compare, Allocator>& c, T&& val)
+ {
+ c.insert(std::move(val));
+ }
+
+ template <typename Container_, typename T>
+ static void push_back(Container_& c, T&& val)
+ {
+ c.push_back(std::move(val));
+ }
+
template <typename T>
static bool call(Container& c, T&& val)
{
- c.insert(c.end(), std::move(val));
+ push_back(c, std::move(val));
return true;
}
};
@@ -154,17 +166,23 @@ namespace boost { namespace spirit { namespace x3 { namespace traits
template <typename Container_>
static void reserve(Container_& c, std::size_t size) {}
- template <typename T>
- static void reserve(std::vector<T>& c, std::size_t size)
+ template <typename T, typename Allocator>
+ static void reserve(std::vector<T, Allocator>& c, std::size_t size)
{
c.reserve(size);
}
+
+ template <typename Container_, typename Iterator>
+ static void insert(Container_& c, Iterator first, Iterator last)
+ {
+ std::copy(first, last, std::inserter(c, c.end()));
+ }
template <typename Iterator>
static bool call(Container& c, Iterator first, Iterator last)
{
reserve(c, c.size() + std::distance(first, last));
- c.insert(c.end(), first, last);
+ insert(c, first, last);
return true;
}
};