Что требуется для создания адаптера std::vector на основе xtensor с формами и шагами?C++

Программы на C++. Форум разработчиков
Anonymous
Что требуется для создания адаптера std::vector на основе xtensor с формами и шагами?

Сообщение Anonymous »

Я сейчас создаю пример xtensor «структуры, включающие форму и шаги», чтобы использовать его для класса изображения с собственной информацией заголовка. Я дошел до этого, поэтому объявил структуру raw_tensor, класс raw_tensor_adaptor, его внутренние типы и базовую семантику. Благодаря этому, а также функции main(), которая просто объявляет объекты класса raw_tensor, компиляция завершается без ошибок.
Однако я не могу этого сделать вещи:
  • добавьте resize() или методы доступа: когда я добавляю функции resize() (без параметра шаблона T ) внутри класса, это не работает, поскольку внутренние типы и члены shape_type, m_shape и т. д. неизвестны. Но это единственное место, где можно перегрузить resize(), верно?
  • добавьте строки с веб-страницы, объявляющие объекты адаптера:

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

    using tensor_type = raw_tensor_adaptor;

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

    tensor_type a, b, c;
Когда я объявляю эти адаптеры, строки a, b, c выдают следующие ошибки:

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

include/xtensor/xiterable.hpp:288:19: error: no type named 'xexpression_type' in 'struct
include/xtensor/xaccessible.hpp:35:15: error: no type named 'reference' in 'struct
include/xtensor/xaccessible.hpp:36:15: error: no type named 'const_reference' in 'struct
include/xtensor/xaccessible.hpp:37:15: error: no type named 'size_type' in 'struct
include/xtensor/xaccessible.hpp:47:48: error: no type named 'const_reference' in 'struct
include/xtensor/xaccessible.hpp:111:26: error: 'at' has not been declared in 'using base_type = class
include/xtensor/xaccessible.hpp:112:35: error: 'operator[]' has not been declared in 'using base_type = class
include/xtensor/xaccessible.hpp:113:26: error: 'back' has not been declared in 'using base_type = class
include/xtensor/xaccessible.hpp:114:26: error: 'front' has not been declared in 'using base_type = class
include/xtensor/xaccessible.hpp:115:26: error: 'periodic' has not been declared in 'using base_type = class
include/xtensor/xcontainer.hpp:79:15: error: no type named 'storage_type' in 'struct
include/xtensor/xcontainer.hpp:80:15: error: no type named 'storage_type' in 'struct
include/xtensor/xcontainer.hpp:82:15: error: no type named 'reference' in 'struct
include/xtensor/xcontainer.hpp:83:15: error: no type named 'const_reference' in 'struct
include/xtensor/xcontainer.hpp:86:15: error: no type named 'size_type' in 'struct
include/xtensor/xcontainer.hpp:88:15: error: no type named 'storage_type' in 'struct
include/xtensor/xcontainer.hpp:89:15: error: no type named 'storage_type' in 'struct
include/xtensor/xcontainer.hpp:107:15: error: no type named 'storage_type' in 'struct
include/xtensor/xcontainer.hpp:108:15: error: no type named 'storage_type' in 'struct
include/xtensor/xcontainer.hpp:140:32: error: 'at' has not been declared in 'using accessible_base = class
include/xtensor/xcontainer.hpp:141:32: error: 'shape' has not been declared in 'using accessible_base = class
include/xtensor/xcontainer.hpp:142:41: error: 'operator[]' has not been declared in 'using accessible_base = class
include/xtensor/xcontainer.hpp:143:32: error: 'back' has not been declared in 'using accessible_base = class
include/xtensor/xcontainer.hpp:144:32: error: 'front' has not been declared in 'using accessible_base = class
include/xtensor/xcontainer.hpp:146:32: error: 'periodic' has not been declared in 'using accessible_base = class
include/xtensor/xcontainer.hpp:182:15: error: no type named 'storage_type' in 'struct
include/xtensor/xsemantic.hpp:64:15: error: no type named 'temporary_type' in 'struct
из заголовков xtensor и

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

test-xtensor/main.cpp:74:36: error: no matching function for call to 'raw_tensor_adaptor::raw_tensor_adaptor()'
74 |         raw_tensor_adaptor < int > b;
|                                    ^
test-xtensor/main.cpp:60:5: note: candidate: 'template raw_tensor_adaptor::raw_tensor_adaptor(const xt::xexpression&) [with T = int]'
60 |     raw_tensor_adaptor(const xt::xexpression& e) : base_type() {
|     ^~~~~~~~~~~~~~~~~~
test-xtensor/main.cpp:60:5: note:   template argument deduction/substitution failed:
test-xtensor/main.cpp:74:36: note:   candidate expects 1 argument, 0 provided
74 |         raw_tensor_adaptor < int > b;
|                                    ^
test-xtensor/main.cpp:56:5: note: candidate: 'raw_tensor_adaptor::raw_tensor_adaptor(raw_tensor_adaptor&&) [with T = int]'
56 |     raw_tensor_adaptor(raw_tensor_adaptor&&) = default;
|     ^~~~~~~~~~~~~~~~~~
test-xtensor/main.cpp:56:5: note:   candidate expects 1 argument, 0 provided
test-xtensor/main.cpp:53:5: note: candidate: 'raw_tensor_adaptor::raw_tensor_adaptor(const raw_tensor_adaptor&) [with T = int]'
53 |     raw_tensor_adaptor(const raw_tensor_adaptor&) = default;
|     ^~~~~~~~~~~~~~~~~~
test-xtensor/main.cpp:53:5: note:   candidate expects 1 argument, 0 provided
из файла .cpp
На веб-странице предлагается определить семантику и реализовать методы и функции, специфичные для класс raw_tensor. Но у меня такое ощущение, что я делаю это не в том месте.
Кто-нибудь нашел этот пример для работы с экземпляром raw_tensor_adaptor?
Большое спасибо!

Подробнее здесь: https://stackoverflow.com/questions/787 ... -shapes-an

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