@@ -44,36 +44,44 @@ namespace tensor
44
44
namespace py_internal
45
45
{
46
46
47
+ namespace concat_impl
48
+ {
49
+
47
50
struct sink_t
48
51
{
49
52
sink_t (){};
50
53
template <class T > sink_t (T &&){};
51
54
};
52
55
53
- template <class V > std::size_t accumulate_size (std::size_t &s, V &&v)
56
+ template <class V > std::size_t __accumulate_size (std::size_t &s, V &&v)
54
57
{
55
58
return s += v.size ();
56
59
}
57
60
58
- template <class V , class U > sink_t inserter (V &lhs, U &&rhs)
61
+ template <class V , class U > sink_t __appender (V &lhs, U &&rhs)
59
62
{
60
63
lhs.insert (lhs.end (), rhs.begin (), rhs.end ());
61
64
return {};
62
65
}
63
66
67
+ } // namespace concat_impl
68
+
64
69
template <typename T, typename A, typename ... Vs>
65
70
std::vector<T, A> concat (std::vector<T, A> lhs, Vs &&...vs)
66
71
{
72
+ using concat_impl::__accumulate_size;
73
+ using concat_impl::__appender;
74
+ using concat_impl::sink_t ;
67
75
std::size_t s = lhs.size ();
68
76
{
69
77
// limited scope ensures array is freed
70
- [[maybe_unused]] sink_t tmp[] = {accumulate_size (s, vs)..., 0 };
78
+ [[maybe_unused]] sink_t tmp[] = {__accumulate_size (s, vs)..., 0 };
71
79
}
72
80
lhs.reserve (s);
73
81
{
74
- // array of no-data objects ensures ordering of calls to inserter
75
- [[maybe_unused]] sink_t tmp[] = {inserter (lhs, std::forward<Vs>(vs))...,
76
- 0 };
82
+ // array of no-data objects ensures ordering of calls to the appender
83
+ [[maybe_unused]] sink_t tmp[] = {
84
+ __appender (lhs, std::forward<Vs>(vs))..., 0 };
77
85
}
78
86
79
87
return std::move (lhs); // prevent return-value optimization
0 commit comments