Question: I went through several discussion, tutorials etc. and I've a feeling like there is no way to inform the user using prototype, that his function might throw an exception.

For instance:

```
/* AudioStream.h */
class AudioStream
{
   int open(struct stream_settings &settings);
}

```

```
/* AudioStream.cpp */
int AudioStream::open(struct stream_settings &settings)
{
    int err;
    err = snd_pcm_open(...);
    if (err < 0)
    {
        /* Throw some exception here */
    }
}

```

If the final product ends up in a library with a header. How does one figures out, that the open function throws an exception and it's necessary to put it into a try/catch block?

Thank you for all the great answers.

Answer: 
Unlike some languages which indicate in the function signature that it "throws", C++ has no such mechanism. This is something you must establish in the documentation or comments near the function definition.
C++ had [`throw` specification](https://en.cppreference.com/w/cpp/language/except_spec) that is deprecated since C++ 11 and could be used like this:

```
void f() throw(int);

```

but the absence of this specifier in the function prototype did NOT guarantee that function won't throw 

Starting from C++ 11 there is [noexcept specifier](https://en.cppreference.com/w/cpp/language/noexcept_spec):

```
void f() noexcept; // the function f() does not throw
void (*fp)() noexcept(false); // fp points to a function that may throw

```

but again

> 
> noexcept specification on a function is not a compile-time check; it is merely a method for a programmer to inform the compiler whether or not a function should throw exceptions
> 
> 
> 

The above code samples are taken from linked pages and you can read more about these specifiers there. 

UPDATE: Following @FrançoisAndrieux suggestion I want to add that although it is not compile-time check *you* can check at compile time whether a function has this specifier or not, which might help you to optimize your code