В C++20 у меня есть определение шаблонной структуры, как показано ниже.
template
struct StateHolder {
std::deque messages;
std::mutex mutex;
std::condition_variable notifier;
};
Для определенного типа я хочу исключить объявление элемента messages.
template
struct StateHolder {
std::mutex mutex;
std::condition_variable notifier;
};
Когда я делаю это в файле заголовка, каким-то образом я получаю следующую ошибку с g++ 11.4.0.
ошибка: явная специализация в области, не относящейся к пространству имен
Какое возможное решение этой проблемы?
При необходимости весь файл выглядит так, как показано ниже
namespace Foo {
class Bar {
// Some other declarations
template
struct StateHolder {
std::deque messages;
std::mutex mutex;
std::condition_variable notifier;
};
template
struct StateHolder {
std::mutex mutex;
std::condition_variable notifier;
};
StateHolder m_integers;
StateHolder m_nothing;
};
};
Подробнее здесь: https://stackoverflow.com/questions/785 ... ialization