В качестве простого примера рассмотрим следующий класс:
Код: Выделить всё
template
class A {
private:
std::array m_vs = {};
public:
int size() {return N;}
void set_value(double d, int n=0) {m_vs[n] = d;}
double get_value(int n=0) {return m_vs[n];}
}
I would like the compiler to throw an error if I type a.set_value(1, 20) since it is known that this will be out of bounds, but not throw any error if I write a.set_value(1, i) since i could be valid.
Is it possible to get such behaviour?
Источник: https://stackoverflow.com/questions/781 ... nown-to-th