1 - 'traits/logger .h' определяет концепцию, например (коротко):
Код: Выделить всё
namespace tenacitas::lib::traits {
template
concept logger = requires(t p_t) {
{
p_t.deb(std::declval(),
std::declval() =
std::source_location::current())
} -> std::same_as;
...
};
}
3 – в 'log/cerr.h` мы имеем:
Код: Выделить всё
namespace tenacitas::lib::log {
using cerr = tenacitas::lib::log::internal::logger std::same_as;
};
template
requires std::move_constructible && std::copy_constructible
struct circular_queue {
using data = t_data;
using logger = typename t_circular_queue_supplier::logger;
...
private:
logger &m_logger;
...
};
}
Код: Выделить всё
struct supplier {
using logger = tenacitas::lib::log::cerr;
logger &get_logger() { return m_log; };
private:
logger m_log;
};
bool test(){
supplier _supplier;
container::circular_queue queue(_supplier);
...
}
Когда я пытаюсь собрать с помощью gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, я получаю:
Код: Выделить всё
‘supplier’ has a field ‘supplier::m_log’ whose type uses the anonymous namespace [-Werror=subobject-linkage]
Код: Выделить всё
‘tenacitas::lib::container::circular_queue’ has a field ‘tenacitas::lib::container::circular_queue::m_log’ whose type uses the anonymous namespace [-Werror=subobject-linkage]
Есть идеи?
Подробнее здесь: https://stackoverflow.com/questions/781 ... -namespace
Мобильная версия