is domain_error in both <stdexcept> & <vector>?

I'm using VS++ 2008 V9 with Vista 64 SP1.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <vector>

using std::domain_error;

int main()
{
	try
	{
		return 0;
	}
	catch (domain_error)
	{
		return 1;
	}
}


This compiles and works fine. In the actual project, I had neglected to add in

 
#include <stdexcept> 


but noticed that domain_error was usable (because of #include <vector>, apparently).

Is domain_error defined in vector also? Is it defined in all containers? Why use stdexcept besides convention?
Is it because <stdexcept> is included in <vector>? Probably so. Therefore, the idea is to always use <stdexcept> because you really don't know definitively if it is used in another template?
You are right; <vector> is directly or indirectly including <stdexcept>.

Simply stated, you should not rely upon a header file including another header you need.
When using std::domain_error, you should include <stdexcept>.
Topic archived. No new replies allowed.