Exception and stdxception headers?

When I inlude <stdexception> header, does that header include <exception> header as well?

I know all standard exceptions inherit from Exception class but why that header is sepereate then?

anyway if we don't inlucde neather of them, how exception handling system does handle those exception then, it looks to that those headers are included in all other std headers, isn'it?

thanks.
The header is called <stdexcept>. To inherit from std::exception they need to have the declaration of std::exception available so it doesn't make much sense not to include <exception> in <stdexcept>. I can't find anything in the standard that say <stdexcept> must include <exception> so I guess it doesn't have to do that but on most implementations it's probably included.
Last edited on
There's a lot more than just the definition of std::exception in the header <exception>. It's plausible that some implementation's <stdexcept> includes a small internal header that defines std::exception, but does not include the header <exception>.
Ok guys, I don't know why I didn't do that before but I've just opened <stdexcept> header and it does inlclude <exception> !

here is what I found in it:

1
2
3
4
5
6
7
8
9
10
11
// stdexcept standard header
#pragma once
#ifndef _STDEXCEPT_
#define _STDEXCEPT_
#ifndef RC_INVOKED
#include <exception>
#include <xstring>

 #pragma pack(push,_CRT_PACKING)

// ETC...... 


I found also that some other headers include <exception> but not all of them..

litle strange, but I think each header should include <exception> since all classes may throw some kind of execption :>?
Topic archived. No new replies allowed.