1 #ifndef MEDUSA_BITS_UTILS_STDTYPESUTILS_HPP_
2 #define MEDUSA_BITS_UTILS_STDTYPESUTILS_HPP_
16 #include <type_traits>
27 std::vector<std::string>
split(
const std::string& s,
const std::string& delim);
29 std::vector<std::string>
split(
const std::string& s,
char delim);
37 std::string
join(
const std::vector<std::string>& parts,
const std::string& joiner);
39 std::string
join(
const std::vector<std::string>& parts,
char joiner);
42 template<
typename container_t>
43 container_t&
sort(container_t& v) {
49 template<
typename container_t,
typename predicate_t>
50 container_t&
sort(container_t& v,
const predicate_t& pred) {
56 template<
typename container_t>
63 template<
typename container_t,
typename predicate_t>
64 container_t
sorted(container_t v,
const predicate_t& pred) {
77 template <
typename container_t,
typename T>
78 container_t
pad(container_t container, T value) {
79 decltype(container.begin()->size()) maxsize = 0;
80 for (
const auto& x : container) {
81 if (x.size() > maxsize) {
85 for (
auto& x : container) {
86 for (
auto i = x.size(); i < maxsize; ++i) x.push_back(value);
97 template <
typename T,
typename Tuple>
100 static const std::size_t
value = -1;
101 static_assert(!std::is_same<Tuple, std::tuple<>>::
value,
102 "Could not get index of type `T` in given `Tuple`");
106 template <
typename T,
typename... Types>
112 template <
typename T,
typename U,
typename... Types>
119 template <
typename T,
typename Tuple>
123 template <
typename T>
127 template <
typename T,
typename U,
typename... Ts>
131 template <
typename T,
typename... Ts>
136 #endif // MEDUSA_BITS_UTILS_STDTYPESUTILS_HPP_