11 #ifndef PQXX_H_SEPARATED_LIST
12 #define PQXX_H_SEPARATED_LIST
14 #include "pqxx/compiler-public.hxx"
15 #include "pqxx/internal/compiler-internal-pre.hxx"
20 #include "pqxx/strconv.hxx"
38 template<
typename ITER,
typename ACCESS>
39 [[nodiscard]]
inline std::string
50 using elt_type =
strip_t<decltype(access(begin))>;
53 std::size_t budget{0};
54 for (ITER cnt{begin}; cnt != end; ++cnt)
55 budget += traits::size_buffer(access(cnt));
56 budget +=
static_cast<std::size_t
>(std::distance(begin, end)) * sep.size();
62 char *stop{here + budget};
63 here = traits::into_buf(here, stop, access(begin)) - 1;
64 for (++begin; begin != end; ++begin)
66 here += sep.copy(here, sep.size());
67 here = traits::into_buf(here, stop, access(begin)) - 1;
69 result.resize(
static_cast<std::size_t
>(here -
result.data()));
75 template<
typename ITER>
76 [[nodiscard]]
inline std::string
84 template<
typename CONTAINER>
85 [[nodiscard]]
inline auto
92 ->
typename std::enable_if<
93 (not std::is_void<decltype(std::begin(c))>::value and
94 not std::is_void<decltype(std::end(c))>::value),
103 typename TUPLE, std::size_t INDEX = 0,
typename ACCESS,
104 typename std::enable_if<
105 (INDEX == std::tuple_size<TUPLE>::value - 1),
int>::type = 0>
107 std::string_view , TUPLE
const &t, ACCESS
const &access)
109 return to_string(access(&std::get<INDEX>(t)));
113 typename TUPLE, std::size_t INDEX = 0,
typename ACCESS,
114 typename std::enable_if<
115 (INDEX < std::tuple_size<TUPLE>::value - 1),
int>::type = 0>
116 [[nodiscard]]
inline std::string
117 separated_list(std::string_view sep, TUPLE
const &t, ACCESS
const &access)
119 std::string out{
to_string(access(&std::get<INDEX>(t)))};
121 out.append(separated_list<TUPLE, INDEX + 1>(sep, t, access));
126 typename TUPLE, std::size_t INDEX = 0,
127 typename std::enable_if<
128 (INDEX <= std::tuple_size<TUPLE>::value),
int>::type = 0>
129 [[nodiscard]]
inline std::string
132 return separated_list(sep, t, [](TUPLE
const &tup) {
return *tup; });
137 #include "pqxx/internal/compiler-internal-post.hxx"