Код: Выделить всё
#include
#include
struct A {
class iterator {
private:
int i = 0; // compiles if "= 0" removed
public:
using value_type = bool; // compiles if line removed
using difference_type = std::ptrdiff_t;
iterator() = default; // compiles if replaced by iterator(){}
iterator(int i) : i(i) {}
bool operator*() const { return false; } // compiles if line removed
iterator &operator++() { return *this; }
iterator operator++(int) { return *this; }
bool operator==(const iterator &other) const = default; // compiles if line removed
};
static_assert(std::weakly_incrementable); // compiles if line removed
};
static_assert(std::is_constructible_v);
int main() {
return 0;
}
Может быть, кто-нибудь может объяснить некоторые наблюдаемые особенности поведения в отношении этих закомментированных строк?
У меня такое чувство, что это может быть каким-то образом связано с этим, но тот факт, что эти другие несвязанные изменения строк позволяют снова компилировать, очень странен.
Подробнее здесь: https://stackoverflow.com/questions/798 ... tic-assert
Мобильная версия