Tomographer
v5.4
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 <boost/version.hpp>
#include <boost/units/detail/utility.hpp>
#include <Eigen/Core>
Go to the source code of this file.
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() | |
template<typename X > | |
bool | Tomographer::Tools::isFinite (const X val) |
Test whether floating-point value is finite. More... | |
template<typename IntType > | |
constexpr bool | Tomographer::Tools::additionWillOverflow (IntType a, IntType b) |
Test whether the sum of two integers will cause an overflow/underflow for that integer type. More... | |
template<typename IntType , typename ... IntTypes> | |
constexpr bool | Tomographer::Tools::additionWillOverflow (IntType a, IntType b, IntType c, IntTypes ... rest) |
Test whether the sum of several integers will cause an overflow/underflow for that integer type. More... | |
template<typename IntType > | |
constexpr bool | Tomographer::Tools::multiplicationWillOverflow (IntType a, IntType b) |
Test whether a multiplication of two integers will cause an overflow/underflow for that integer type. More... | |
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... | |
template<typename Archive , typename... TupleArgs> | |
void | boost::serialization::serialize (Archive &a, std::tuple< TupleArgs... > &tuple, const unsigned int version) |
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.