what is a domain error

后端 未结 7 1436

in c++, has a base class for \'domain errors\', std::domain_error. i don\'t understand under what circumstances i should throw a domain error in my code. all

7条回答
  •  梦毁少年i
    2021-02-05 20:00

    "Detailed Description Thrown by the library, or by you, to report domain errors (domain in the mathmatical sense). "

    From: http://www.aoc.nrao.edu/~tjuerges/ALMA/STL/html/classstd_1_1domain__error.html

    according to this, it should be used if you are given input that does not comply with the constraints you put on your interface. Like say, a function that is supposed to receive a positive value and is given a negative one.

提交回复
热议问题