Я пытаюсь использовать следующие предложения для приведения изображения к различным типам (я использую библиотеку ITK 5.1, если это помогает):
if (outputPixelType == std::string("double"))
{
using OutputPixelType = double;
}
else
{
using OutputPixelType = int;
}
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
Я получаю ошибку, подобную этой, с помощью компилятора clang
error: use of undeclared identifier 'OutputPixelType'; did you mean 'outputPixelType'?
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
^~~~~~~~~~~~~~~
outputPixelType
Но если я использую следующие предложения, это работает.
using OutputPixelType = int;
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
Почему оператор if
не работает? Как это исправить? Спасибо.
Я попробовал следующую команду, используя комментарий Довахина:
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
После компиляции я получил другую ошибку:
error: expected a type
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
^
error: type-id cannot have a name
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
^~~~~~~~~~~~~~~
error: expected ')'
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
^
note: to match this '('
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
^
error: expected ';' after alias declaration
using OutputPixelType = (outputPixelType == std::string("double")) ? double : int16_t;
Кажется, что using
не принимает ()? A: B оператор.