|
Tomographer
v4.0
Tomographer C++ Framework Documentation
|
Some C++ utilities, with a tad of C++11 tricks. More...
#include <cassert>#include <cstddef>#include <cstdlib>#include <iostream>#include <complex>#include <type_traits>#include <exception>#include <stdexcept>#include <tomographer/tools/cxxdefs.h>#include <tomographer/tools/conststr.h>#include <Eigen/Core>
Include dependency graph for cxxutil.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| class | Tomographer::Tools::StaticOrDynamic< T_, IsDynamic_, StaticValue_ > |
| A type which stores a value possibly known at compile-time. More... | |
| class | Tomographer::Tools::StaticOrDynamic< T_, true, StaticValue_ > |
| Template Specialization – see StaticOrDynamic<T_,IsDynamic_,StaticValue_> More... | |
| struct | Tomographer::Tools::StoreIfEnabled< T_, enabled > |
| Utility that stores a data type if a compile-time flag is enabled. More... | |
| struct | Tomographer::Tools::StoreIfEnabled< T_, true > |
| Specialization of StoreIfEnabled<T_,enabled> for if we're storing a value. More... | |
| struct | Tomographer::Tools::ComplexRealScalar< Scalar > |
| The Real scalar type corresponding to a std::complex type. More... | |
| struct | Tomographer::Tools::ComplexRealScalar< std::complex< RealScalar > > |
| Implementation of ComplexRealScalar for complex types. More... | |
Namespaces | |
| Tomographer | |
Base namespace for the Tomographer project. | |
| Tomographer::Tools | |
| Various useful tools. | |
Macros | |
| #define | PRINTF1_ARGS_SAFE |
| #define | PRINTF2_ARGS_SAFE |
| #define | PRINTF3_ARGS_SAFE |
| #define | PRINTF4_ARGS_SAFE |
| #define | TOMOGRAPHER_CXX_STACK_FORCE_REALIGN |
| #define | TOMO_FUNCTION __PRETTY_FUNCTION__ |
| Expands to the current function name or signature. More... | |
| #define | TOMOGRAPHER_DEFINE_MSG_EXCEPTION(ClassName, ErrPrefix) |
| Define a simple exception class. More... | |
| #define | TOMOGRAPHER_DEFINE_MSG_EXCEPTION_BASE(ClassName, ErrPrefix, BaseClass) |
| Define a simple exception class. More... | |
Functions | |
| template<typename F > | |
| tomo_internal::FinalAction< F > | Tomographer::Tools::finally (F f) |
implementation of a finally clause, somewhat like in Python More... | |
| template<typename T > | |
| std::ostream & | Tomographer::Tools::operator<< (std::ostream &str, const StoreIfEnabled< T, false > &) |
| C++ Stream operators for StoreIfEnabled. More... | |
| template<typename T > | |
| std::ostream & | Tomographer::Tools::operator<< (std::ostream &str, const StoreIfEnabled< T, true > &val) |
| C++ Stream operators for StoreIfEnabled. More... | |
| template<typename IntType = int> | |
| constexpr bool | Tomographer::Tools::isPowerOfTwo (IntType N) |
| Return true if the argument is a power of two, false otherwise. | |
| template<typename X > | |
| std::enable_if< std::is_unsigned< X >::value, bool >::type | Tomographer::Tools::isPositive (const X) |
| Test whether the given value is positive or zero. More... | |
| template<typename X > | |
| std::enable_if<!std::is_unsigned< X >::value, bool >::type | Tomographer::Tools::isPositive (const X val) |
| See isPositive() | |
| int | Tomographer::Tools::getWidthForTerminalOutput (int max_width=0) |
| Return a suitable width for displaying stuff on the standard output. More... | |
| constexpr conststr | Tomographer::Tools::extractFuncName (const conststr &funcname) |
| Extract the function name from its signature. More... | |
| template<typename ExceptionClass = std::runtime_error> | |
| void | Tomographer::Tools::tomographerEnsure (bool condition, std::string message) |
| Ensure that a condition is met, or throw an exception. More... | |
Some C++ utilities, with a tad of C++11 tricks.
Definition in file cxxutil.h.
| #define TOMO_FUNCTION __PRETTY_FUNCTION__ |
Expands to the current function name or signature.
For Tomographer::Logger::LocalLogger, use TOMO_ORIGIN.
| #define TOMOGRAPHER_CXX_STACK_FORCE_REALIGN |
Force stack realign for some functions, where the stacks may not aligned by default (e.g. when using threads for Windows—set this attribute to any external entry points as http://stackoverflow.com/a/6718067/1694896 as well as http://www.peterstock.co.uk/games/mingw_sse/)
| #define TOMOGRAPHER_DEFINE_MSG_EXCEPTION | ( | ClassName, | |
| ErrPrefix | |||
| ) |
Define a simple exception class.
This macro defines a class named ClassName which derives from std::exception. The constructor is given a string (the error message) which it prefixes with the given ErrPrefix to form the full error message.
The exception class consists of:
const char * what() const noexcept retrieves the string passed to the constructor (including the error prefix).std::string msg() const noexcept allows to retrieve the message string as an std::string (also including the error prefix).Example usage:
| #define TOMOGRAPHER_DEFINE_MSG_EXCEPTION_BASE | ( | ClassName, | |
| ErrPrefix, | |||
| BaseClass | |||
| ) |
Define a simple exception class.
In contrast to TOMOGRAPHER_DEFINE_MSG_EXCEPTION, the newly defined class does not itself store the error message. Rather, it passes it on to the base class BaseClass which is responsible of storing it and returning a meaningful what() string.
There is also no msg() method provided.