Tomographer  v1.0a
Tomographer C++ Framework Documentation
util.h File Reference

(v1.0a)

Some C++ utilities, with a tad of C++11 tricks. More...

#include <type_traits>
#include <Eigen/Core>
#include <tomographer/tools/conststr.h>
+ Include dependency graph for util.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Tomographer::Tools::static_or_dynamic< T_, Value >
 A type which stores a value possibly known at compile-time. More...
 
class  Tomographer::Tools::static_or_dynamic< T_, Eigen::Dynamic >
 Template Specialization – see static_or_dynamic<T_,Value> More...
 
struct  Tomographer::Tools::store_if_enabled< T_, enabled >
 Utility that stores a data type if a compile-time flag is enabled. More...
 
struct  Tomographer::Tools::store_if_enabled< T_, true >
 Specialization of store_if_enabled<T_,enabled> for if we're storing a value. More...
 

Namespaces

 Tomographer
 Base namespace for the Tomographer project.
 
 Tomographer::Tools
 Various useful tools.
 

Macros

#define PRINTF1_ARGS_SAFE   __attribute__ ((__format__ (__printf__, 1, 2)))
 attributes for a function accepting printf-like variadic arguments More...
 
#define PRINTF2_ARGS_SAFE   __attribute__ ((__format__ (__printf__, 2, 3)))
 See PRINTF1_ARGS_SAFE.
 
#define PRINTF3_ARGS_SAFE   __attribute__ ((__format__ (__printf__, 3, 4)))
 See PRINTF1_ARGS_SAFE.
 
#define PRINTF4_ARGS_SAFE   __attribute__ ((__format__ (__printf__, 4, 5)))
 See PRINTF1_ARGS_SAFE.
 
#define TOMO_FUNCTION   __PRETTY_FUNCTION__
 Expands to the current function name or signature. More...
 
#define TOMO_STATIC_ASSERT_EXPR(...)   static_assert(__VA_ARGS__, #__VA_ARGS__)
 Tool for static assertions without message. 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::ostreamTomographer::Tools::operator<< (std::ostream &str, store_if_enabled< T, false >)
 C++ Stream operators for store_if_enabled<T,enabled> More...
 
template<typename T >
std::ostreamTomographer::Tools::operator<< (std::ostream &str, store_if_enabled< T, true > val)
 C++ Stream operators for store_if_enabled<T,enabled> More...
 
constexpr bool Tomographer::Tools::is_power_of_two (int N)
 Return true if the argument is a power of two, false otherwise.
 
constexpr conststr Tomographer::Tools::extractFuncName (const conststr &funcname)
 Extract the function name from its signature. More...
 

Detailed Description

Some C++ utilities, with a tad of C++11 tricks.

Definition in file util.h.

Macro Definition Documentation

#define PRINTF1_ARGS_SAFE   __attribute__ ((__format__ (__printf__, 1, 2)))

attributes for a function accepting printf-like variadic arguments

Put this macro in front of custom functions which accept printf-like formatted arguments. The attributes which this macro expands to instructs the compiler to warn the user against wrong printf formats.

Use the macro PRINTF1_ARGS_SAFE if the format string is the first argument of the function and the arguments immediately follow, i.e. if the function has signature

1 <return-type> function(const char * fmt, ...);

If you have other arguments preceeding the format string, use the respective macros PRINTF2_ARGS_SAFE, PRINTF3_ARGS_SAFE or PRINTF4_ARGS_SAFE. Note that for non-static class members there is always the implicit this parameter, so you should count the arguments starting from 2, not 1.

See also the `format' attribute at https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes .

Definition at line 72 of file util.h.

#define TOMO_FUNCTION   __PRETTY_FUNCTION__

Expands to the current function name or signature.

For Logger::LocalLogger, use TOMO_ORIGIN.

Definition at line 294 of file util.h.

#define TOMO_STATIC_ASSERT_EXPR (   ...)    static_assert(__VA_ARGS__, #__VA_ARGS__)

Tool for static assertions without message.

Simply use as message to C++11's static_assert() a stringified version of the expression itself.

Definition at line 363 of file util.h.