X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9104957deccc59e0e804215d5db498fabfd40d29..39c935d6d5ee86d153f6f7e6a10d723ae7c57f6f:/include/xbt/utility.hpp diff --git a/include/xbt/utility.hpp b/include/xbt/utility.hpp index c39cf85725..2a1541ac8a 100644 --- a/include/xbt/utility.hpp +++ b/include/xbt/utility.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2016-2020. The SimGrid Team. +/* Copyright (c) 2016-2021. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -47,69 +47,6 @@ template inline void intrusive_erase(List& list, Elem& list.erase(list.iterator_to(elem)); } -// integer_sequence and friends from C++14 -// We need them to implement `apply` from C++17. - -/** A compile-time sequence of integers (from C++14) - * - * `index_sequence` represents the sequence `(1,5,7,9)`. - * - * @code{.cpp} - * template - * auto extract_tuple(T&& t, integer_sequence) - * -> decltype(std::make_tuple(std::get(std::forward(t))...)) - * { - * return std::make_tuple(std::get(std::forward(t))...); - * } - * - * int main() - * { - * integer_sequence seq; - * auto a = std::make_tuple(1, 2.0, false, 'a'); - * auto b = extract_tuple(a, seq); - * std::cout << std::get<0>(b) << '\n'; // 2 - * std::cout << std::get<1>(b) << '\n'; // a - * return 0; - * } - * @endcode - */ -template -class integer_sequence { -}; - -namespace bits { - template - struct make_integer_sequence : - make_integer_sequence - {}; - template - struct make_integer_sequence { - typedef integer_sequence type; - }; -} - -/** A compile-time sequence of integers of the form `(0,1,2,3,...,N-1)` (from C++14) */ -template -using make_integer_sequence = typename simgrid::xbt::bits::make_integer_sequence::type; - -/** A compile-time sequence of indices (from C++14) */ -template -using index_sequence = integer_sequence; - -/** A compile-time sequence of indices of the form `(0,1,2,3,...,N-1)` (from C++14) */ -template -using make_index_sequence = make_integer_sequence; - -/** Convert a type parameter pack into a index_sequence (from C++14) */ -template -using index_sequence_for = make_index_sequence; - -static_assert(std::is_same< make_index_sequence<0>, index_sequence<> >::value, "seq0"); -static_assert(std::is_same< make_index_sequence<1>, index_sequence<0> >::value, "seq1"); -static_assert(std::is_same< make_index_sequence<2>, index_sequence<0, 1> >::value, "seq2"); -static_assert(std::is_same< make_index_sequence<3>, index_sequence<0, 1, 2> >::value, "seq3"); -static_assert(std::is_same< index_sequence_for, make_index_sequence<3> >::value, "seq4"); - } } #endif