Сделать черту типа для вращения index_sexences больше компилятора.C++

Программы на C++. Форум разработчиков
Ответить
Anonymous
 Сделать черту типа для вращения index_sexences больше компилятора.

Сообщение Anonymous »

Я создал черту типа для создания пакета типа вращающихся индексных последовательностей: < /p>

Код: Выделить всё

#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
s, компиляторы начинают испытывать проблемы (заканчиваются в пространстве кучи, выводятся в Compler Explorer и т. Д.). clang and icx manages 700+ and gcc and MSVC fail long before that (playground @ Compiler Explorer).
  • My goal is to get gcc, clang, icx and MSVC to all manage 700+ rotations (without timing out in Compiler Explorer).
Мой текущий подход наивенно добавляет один index_sexence < /code> за раз в результате рекурсивного наследования: < /p>

Код: Выделить всё

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
, кажется, в значительной степени не затронута этой попыткой. Мне нужны свежие глаза на это. < /P>

Эта черта типа используется в качестве детализации реализации в коде, который доступен для просмотра в ряде вопросов. См. Отдельно стоящий try_lock_for /try_lock_until .


Подробнее здесь: https://stackoverflow.com/questions/797 ... r-friendly
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C++»