Quantum++  v1.0
A modern C++11 quantum computing library
qpp::exception::Exception Class Referenceabstract

Base class for generating Quantum++ custom exceptions. More...

#include <classes/exception.h>

Inheritance diagram for qpp::exception::Exception:
Collaboration diagram for qpp::exception::Exception:

Public Member Functions

 Exception (const std::string &where)
 Constructs an exception. More...
 
virtual const char * what () const noexcept override
 Overrides std::exception::what() More...
 
virtual std::string type_description () const =0
 Exception type description. More...
 

Private Attributes

std::string where_
 
std::string msg_
 

Detailed Description

Base class for generating Quantum++ custom exceptions.

Derive from this class if more exceptions are needed, making sure to override qpp::exception::Exception::type_description() in the derived class and to inherit the constructor qpp::exception::Exception::Exception(). Preferably keep your newly defined exception classes in the namespace qpp::exception.

Example:

namespace qpp
{
namespace exception
{
class ZeroSize : public Exception
{
public:
std::string type_description() const override
{
return "Object has zero size";
}
// inherit the base class' qpp::exception::Exception constructor
};
} // namespace exception
} // namespace qpp

Constructor & Destructor Documentation

◆ Exception()

qpp::exception::Exception::Exception ( const std::string &  where)
inline

Constructs an exception.

Parameters
whereText representing where the exception occurred

Member Function Documentation

◆ type_description()

◆ what()

virtual const char* qpp::exception::Exception::what ( ) const
inlineoverridevirtualnoexcept

Overrides std::exception::what()

Returns
Exception description

Member Data Documentation

◆ msg_

std::string qpp::exception::Exception::msg_
mutableprivate

◆ where_

std::string qpp::exception::Exception::where_
private

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