Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iterator>
- #include <algorithm>
- #include <array>
- using namespace std;
- namespace impl {
- template<class T, size_t N1, size_t N2>
- array<T, N1 + N2>
- constexpr operator >>(const array<T, N1>& array1, const array<T, N2>& array2) {
- array<T, N1 + N2> result {};
- copy(array1.begin(), array1.end(), result.begin());
- copy(array2.begin(), array2.end(), result.begin() + array1.size());
- return result;
- }
- template<class... Args>
- constexpr auto concat(Args&&... args) {
- return (... >> args);
- }
- }
- using impl::concat;
- int main() {
- constexpr array a {1, 2, 3, 4};
- constexpr array b {4, 5, 6};
- constexpr auto a_and_b = concat(a, b, a, b);
- static_assert(a_and_b.size() == 14);
- static_assert(a_and_b[5] == 5);
- static_assert(a_and_b[12] == 5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement