HyperHDG
Macros
compile_time_tricks.hxx File Reference
#include <limits>
#include <type_traits>
#include <utility>
Include dependency graph for compile_time_tricks.hxx:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define UNUSED(x)   /* nothing */
 Unused parametes will neither result in g++, nor in doxygen warnings if wrapped by this. More...
 
#define HAS_MEMBER_FUNCTION(func, name)
 Check if some class implements some function with some signature. More...
 

Macro Definition Documentation

◆ HAS_MEMBER_FUNCTION

#define HAS_MEMBER_FUNCTION (   func,
  name 
)
Value:
template <typename, typename T> \
struct name \
{ \
static_assert(std::integral_constant<T, false>::value, \
"Second template parameter must be function signature."); \
}; \
template <typename C, typename Ret, typename... Args> \
struct name<C, Ret(Args...)> \
{ \
private: \
template <typename T> \
static constexpr auto check(T*) -> \
typename std::is_same<decltype(std::declval<T>().func(std::declval<Args>()...)), Ret>::type; \
template <typename> \
static constexpr std::false_type check(...); \
typedef decltype(check<C>(0)) type; \
\
public: \
static constexpr bool value = type::value; \
}

Check if some class implements some function with some signature.


This macro receives the name of the function that is checked to be implemented with a given signature (not handled to the macro itself) and the name of a struct (output) that can be used to check whether function func is implemented.

Having invoked the macro, we are able to use the template struct name to check whether function fun is a (static or non-static) member function of an element of class C, where Ret(Args) is the supposed signature.

Parameters
[in]funcThe name of the function that is checked to be implemented.
[out]nameThe resulting struct whose value is true if the function is implemented.

◆ UNUSED

#define UNUSED (   x)    /* nothing */

Unused parametes will neither result in g++, nor in doxygen warnings if wrapped by this.


public
we sometimes make exceptions for this Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally NO WARRANTY BECAUSE THE LIBRARY IS LICENSED FREE OF THERE IS NO WARRANTY FOR THE TO THE EXTENT PERMITTED BY APPLICABLE LAW EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND OR OTHER PARTIES PROVIDE THE LIBRARY AS IS WITHOUT WARRANTY OF ANY EITHER EXPRESSED OR BUT NOT LIMITED THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU SHOULD THE LIBRARY PROVE YOU ASSUME THE COST OF ALL NECESSARY REPAIR OR CORRECTION IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT OR ANY OTHER PARTY WHO MAY MODIFY AND OR REDISTRIBUTE THE LIBRARY AS PERMITTED BE LIABLE TO YOU FOR INCLUDING ANY INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new and you want it to be of the greatest possible use to the public
Definition: License.txt:463