Scarab  v3.4.0
Project 8 C++ Utility Library
Public Member Functions | Protected Attributes | List of all members
base_exception< x_derived > Class Template Reference

Base class for exceptions with streaming operators. More...

#include <base_exception.hh>

Inheritance diagram for base_exception< x_derived >:
Inheritance graph

Public Member Functions

 base_exception ()
 
 base_exception (const base_exception< x_derived > &a_orig)
 
virtual ~base_exception () noexcept
 
base_exception< x_derived > & operator= (const base_exception< x_derived > &a_orig)
 
template<class x_streamable >
x_derived & operator<< (x_streamable a_fragment)
 
x_derived & operator<< (const std::string &a_fragment)
 
x_derived & operator<< (const char *a_fragment)
 
virtual const char * what () const noexcept
 

Protected Attributes

std::string f_error
 

Detailed Description

template<typename x_derived>
class scarab::base_exception< x_derived >

Base class for exceptions with streaming operators.

Author
N.S. Oblath

This class provides streaming operators for building up the what() message. It's meant to be the base class for any exceptions wanting to use that feature.

This class uses the Curiously Recurring Template Pattern (CRTP) to get the derived class type to appear in the base class. In particular, we need to return x_derived& from the various operator<<() so that those functions can be used in a throw statement and the user can still catch the derived type.

Definition at line 35 of file base_exception.hh.

Constructor & Destructor Documentation

◆ base_exception() [1/2]

Definition at line 56 of file base_exception.hh.

◆ base_exception() [2/2]

base_exception ( const base_exception< x_derived > &  a_orig)

Definition at line 62 of file base_exception.hh.

◆ ~base_exception()

~base_exception ( )
virtualnoexcept

Definition at line 68 of file base_exception.hh.

Member Function Documentation

◆ operator<<() [1/3]

x_derived & operator<< ( x_streamable  a_fragment)

Definition at line 86 of file base_exception.hh.

◆ operator<<() [2/3]

x_derived & operator<< ( const std::string &  a_fragment)

Definition at line 95 of file base_exception.hh.

◆ operator<<() [3/3]

x_derived & operator<< ( const char *  a_fragment)

Definition at line 102 of file base_exception.hh.

◆ operator=()

base_exception< x_derived > & operator= ( const base_exception< x_derived > &  a_orig)

Definition at line 72 of file base_exception.hh.

◆ what()

const char * what ( ) const
virtualnoexcept

Definition at line 79 of file base_exception.hh.

Member Data Documentation

◆ f_error

std::string f_error
mutableprotected

Definition at line 52 of file base_exception.hh.


The documentation for this class was generated from the following file: