Код: Выделить всё
#include
#include
template
struct type_pack {};
template
using make_pack_of_rotating_index_sequences = ...;
< /code>
make_pack_of_rotating_index_sequencesКод: Выделить всё
type_pack
< /code>
However, with large N- My goal is to get gcc, clang, icx and MSVC to all manage 700+ rotations (without timing out in Compiler Explorer).
Код: Выделить всё
template
struct type_pack {}; // seems to compile slightly faster than using a tuple
namespace rot_detail {
template // primary, not implemented
struct rot_help;
template // empty sequence entry point and terminator
struct rot_help {
using type = type_pack;
};
// extra entry point and terminator needed for MSVC with N=1.
// I tried to report this bug but was "not authorized".
template
struct rot_help {
using type = type_pack;
};
template // normal terminator
struct rot_help {
using type = type_pack;
};
template // entry point for non-empty sequence
struct rot_help
: rot_help {};
template // builder
struct rot_help
: rot_help {};
} // namespace rot_detail
template
using make_pack_of_rotating_index_sequences =
rot_detail::rot_help::type;
< /code>
I've also tried a similar approach using function overloads. It's very similar so I don't include it. It also made matters worse so I dropped that idea.
When creating traits using recursive inheritance it's often possible to apply some sort of divide and conquer approach and then to assemble the result at the end to reduce the recursive depth and complexity, and in that spirit I tried to see if I could cut the inheritance depth in half by doing two rotations per pass (Compler Explorer) as long as the next depth doesn't reach the terminator:
template struct two;
template
struct two {
using type = rot_help;
};
template // builder
struct rot_help
: std::conditional_t<
std::same_as,
rot_help,
typename two::type> {};
< /code>
But the compilation time and max NЭта черта типа используется в качестве детализации реализации в коде, который доступен для просмотра в ряде вопросов. См. Отдельно стоящий try_lock_for /try_lock_until .
Подробнее здесь: https://stackoverflow.com/questions/797 ... r-friendly
Мобильная версия