Я не уверен, указано ли в стандарте, что продвижение/разыменование стандартного итератора контейнера не является исключением. GCC и MSVC последовательно исключают их для всех стандартных контейнеров. Но clang делает их noException для std::vector/std::basic_string и noException(false) для std::list/std::set/std::map/std::unordered_set/std::unordered_map.
Пример кода можно найти ниже или на сайте godbolt.
#include
#include
#include
#include
#include
#include
#include
#include
template
concept nothrow_advancable = noexcept(++std::declval());
template
concept nothrow_dereferencable = noexcept(*std::declval());
static_assert(nothrow_advancable);
static_assert(nothrow_advancable);
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_dereferencable);
static_assert(nothrow_dereferencable);
static_assert(nothrow_dereferencable); // not noexcept with clang
static_assert(nothrow_dereferencable); // not noexcept with clang
static_assert(nothrow_dereferencable); // not noexcept with clang
static_assert(nothrow_dereferencable); // not noexcept with clang
static_assert(nothrow_dereferencable); // not noexcept with clang
Подробнее здесь: https://stackoverflow.com/questions/793 ... containers
Почему clang несовместим с noException(++it) и noException(*it) для контейнеров? ⇐ C++
Программы на C++. Форум разработчиков
1736351714
Anonymous
Я не уверен, указано ли в стандарте, что продвижение/разыменование стандартного итератора контейнера не является исключением. GCC и MSVC последовательно исключают их для всех стандартных контейнеров. Но clang делает их noException для std::vector/std::basic_string и noException(false) для std::list/std::set/std::map/std::unordered_set/std::unordered_map.
Пример кода можно найти ниже или на сайте godbolt.
#include
#include
#include
#include
#include
#include
#include
#include
template
concept nothrow_advancable = noexcept(++std::declval());
template
concept nothrow_dereferencable = noexcept(*std::declval());
static_assert(nothrow_advancable);
static_assert(nothrow_advancable);
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_advancable); // not noexcept with clang
static_assert(nothrow_dereferencable);
static_assert(nothrow_dereferencable);
static_assert(nothrow_dereferencable); // not noexcept with clang
static_assert(nothrow_dereferencable); // not noexcept with clang
static_assert(nothrow_dereferencable); // not noexcept with clang
static_assert(nothrow_dereferencable); // not noexcept with clang
static_assert(nothrow_dereferencable); // not noexcept with clang
Подробнее здесь: [url]https://stackoverflow.com/questions/79339644/why-is-clang-not-consistent-on-noexceptit-and-noexceptit-for-containers[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия