Delete sequence_bt.hpp
This stuff has been in the standard lib for a long time now.
This commit is contained in:
parent
422b475ce3
commit
562eba5f68
2 changed files with 6 additions and 60 deletions
|
@ -1,54 +0,0 @@
|
||||||
/* Copyright 2016-2021 Michele Santullo
|
|
||||||
* This file is part of "duckhandy".
|
|
||||||
*
|
|
||||||
* "duckhandy" is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* "duckhandy" is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with "duckhandy". If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef id4FAEF395B9ED47CB9D6B50B54C9A289A
|
|
||||||
#define id4FAEF395B9ED47CB9D6B50B54C9A289A
|
|
||||||
|
|
||||||
#include <cstddef>
|
|
||||||
|
|
||||||
namespace dhandy {
|
|
||||||
namespace bt {
|
|
||||||
template <typename T, T... I>
|
|
||||||
struct number_seq {
|
|
||||||
};
|
|
||||||
|
|
||||||
template <std::size_t... I>
|
|
||||||
using index_seq = number_seq<std::size_t, I...>;
|
|
||||||
|
|
||||||
namespace implem {
|
|
||||||
template <typename T, T MIN, T MAX, T... I>
|
|
||||||
struct range_builder;
|
|
||||||
|
|
||||||
template <typename T, T MIN, T... I>
|
|
||||||
struct range_builder<T, MIN, MIN, I...> {
|
|
||||||
typedef number_seq<T, I...> type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, T MIN, T N, T... I>
|
|
||||||
struct range_builder : public range_builder<T, MIN, N - 1, N - 1, I...> {
|
|
||||||
};
|
|
||||||
} //namespace implem
|
|
||||||
|
|
||||||
template <typename T, T MIN, T MAX>
|
|
||||||
using number_range = typename implem::range_builder<T, MIN, MAX>::type;
|
|
||||||
|
|
||||||
template <std::size_t MIN, std::size_t MAX>
|
|
||||||
using index_range = number_range<std::size_t, MIN, MAX>;
|
|
||||||
} //namespace bt
|
|
||||||
} //namespace dhandy
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -18,7 +18,7 @@
|
||||||
#ifndef id170B0E6C34D14EBA9B92A35977BDBFB3
|
#ifndef id170B0E6C34D14EBA9B92A35977BDBFB3
|
||||||
#define id170B0E6C34D14EBA9B92A35977BDBFB3
|
#define id170B0E6C34D14EBA9B92A35977BDBFB3
|
||||||
|
|
||||||
#include "sequence_bt.hpp"
|
#include <utility>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -58,7 +58,7 @@ namespace dhandy {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <std::size_t... I>
|
template <std::size_t... I>
|
||||||
constexpr string ( const index_seq<I...>&, const value_type* parString );
|
constexpr string ( const std::index_sequence<I...>&, const value_type* parString );
|
||||||
|
|
||||||
const value_type m_data[S];
|
const value_type m_data[S];
|
||||||
};
|
};
|
||||||
|
@ -70,7 +70,7 @@ namespace dhandy {
|
||||||
|
|
||||||
namespace implem {
|
namespace implem {
|
||||||
template <std::size_t S, std::size_t S2, std::size_t... I>
|
template <std::size_t S, std::size_t S2, std::size_t... I>
|
||||||
constexpr string<S + S2 - 1> concat ( const index_seq<I...>&, const string<S>& parLeft, const string<S2>& parRight ) {
|
constexpr string<S + S2 - 1> concat ( const std::index_sequence<I...>&, const string<S>& parLeft, const string<S2>& parRight ) {
|
||||||
return string<S + S2 - 1>(
|
return string<S + S2 - 1>(
|
||||||
(I < S - 1 ? parLeft[I] : (I < S + S2 - 2 ? parRight[I - (S - 1)] : '\0'))...
|
(I < S - 1 ? parLeft[I] : (I < S + S2 - 2 ? parRight[I - (S - 1)] : '\0'))...
|
||||||
);
|
);
|
||||||
|
@ -83,14 +83,14 @@ namespace dhandy {
|
||||||
|
|
||||||
template <std::size_t S, typename Ch>
|
template <std::size_t S, typename Ch>
|
||||||
template <std::size_t... I>
|
template <std::size_t... I>
|
||||||
constexpr string<S, Ch>::string (const index_seq<I...>&, const value_type* parString) :
|
constexpr string<S, Ch>::string (const std::index_sequence<I...>&, const value_type* parString) :
|
||||||
m_data{parString[I]...}
|
m_data{parString[I]...}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t S, typename Ch>
|
template <std::size_t S, typename Ch>
|
||||||
inline constexpr string<S, Ch>::string (const value_type* parString) :
|
inline constexpr string<S, Ch>::string (const value_type* parString) :
|
||||||
string(index_range<0, S>(), parString)
|
string(std::make_index_sequence<S>(), parString)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ namespace dhandy {
|
||||||
template <std::size_t S, typename Ch>
|
template <std::size_t S, typename Ch>
|
||||||
template <std::size_t S2>
|
template <std::size_t S2>
|
||||||
constexpr inline string<S + S2 - 1, Ch> string<S, Ch>::operator+ (const string<S2, Ch>& parOther) const {
|
constexpr inline string<S + S2 - 1, Ch> string<S, Ch>::operator+ (const string<S2, Ch>& parOther) const {
|
||||||
return implem::concat(index_range<0, S + S2 - 1>(), string<S>(m_data), parOther);
|
return implem::concat(std::make_index_sequence<S + S2 - 1>(), string<S>(m_data), parOther);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <std::size_t S, typename Ch>
|
template <std::size_t S, typename Ch>
|
||||||
|
|
Loading…
Add table
Reference in a new issue