Skip to content
Snippets Groups Projects
Commit dd79951b authored by Simon Praetorius's avatar Simon Praetorius
Browse files

undo whitespace changes

parent 2c0a33cd
No related branches found
No related tags found
1 merge request!924WIP: playground for config.h replacement
Pipeline #33199 failed
Showing
with 6517 additions and 6517 deletions
......@@ -14,7 +14,7 @@ def add_config_header(module, dir):
contains_config_header = False
with open(file,'r') as f:
file_content = [line.strip() for line in f.readlines()]
file_content = [line.rstrip() for line in f.readlines()]
for l,line in enumerate(file_content):
if config_header in line:
contains_config_header = True
......
......@@ -11,52 +11,52 @@
namespace Dune
{
/**
@ingroup Allocators
@brief Allocators which guarantee alignment of the memory
@tparam T type of the object one wants to allocate
@tparam Alignment explicitly specify the alignment, by default it is std::alignment_of<T>::value
*/
template<class T, int Alignment = -1>
class AlignedAllocator : public MallocAllocator<T> {
/*
* Check whether an explicit alignment was
* restricted or fall back to the default alignment of T.
*/
static constexpr int fixAlignment(int align)
{
return (Alignment==-1) ? std::alignment_of<T>::value : Alignment;
}
public:
using pointer = typename MallocAllocator<T>::pointer;
using size_type = typename MallocAllocator<T>::size_type;
template <class U> struct rebind {
typedef AlignedAllocator<U,Alignment> other;
};
static constexpr int alignment = fixAlignment(sizeof(void*));
//! allocate n objects of type T
pointer allocate(size_type n, const void* hint = 0)
{
DUNE_UNUSED_PARAMETER(hint);
if (n > this->max_size())
throw std::bad_alloc();
/*
* Everybody else gets the standard treatment.
*/
pointer ret = static_cast<pointer>(std::aligned_alloc(alignment, n * sizeof(T)));
if (!ret)
throw std::bad_alloc();
return ret;
}
};
/**
@ingroup Allocators
@brief Allocators which guarantee alignment of the memory
@tparam T type of the object one wants to allocate
@tparam Alignment explicitly specify the alignment, by default it is std::alignment_of<T>::value
*/
template<class T, int Alignment = -1>
class AlignedAllocator : public MallocAllocator<T> {
/*
* Check whether an explicit alignment was
* restricted or fall back to the default alignment of T.
*/
static constexpr int fixAlignment(int align)
{
return (Alignment==-1) ? std::alignment_of<T>::value : Alignment;
}
public:
using pointer = typename MallocAllocator<T>::pointer;
using size_type = typename MallocAllocator<T>::size_type;
template <class U> struct rebind {
typedef AlignedAllocator<U,Alignment> other;
};
static constexpr int alignment = fixAlignment(sizeof(void*));
//! allocate n objects of type T
pointer allocate(size_type n, const void* hint = 0)
{
DUNE_UNUSED_PARAMETER(hint);
if (n > this->max_size())
throw std::bad_alloc();
/*
* Everybody else gets the standard treatment.
*/
pointer ret = static_cast<pointer>(std::aligned_alloc(alignment, n * sizeof(T)));
if (!ret)
throw std::bad_alloc();
return ret;
}
};
}
......
This diff is collapsed.
......@@ -8,17 +8,17 @@
//! Asserts a condition and return on success in constexpr context.
/**
* The macro DUNE_ASSERT_AND_RETURN can be used as expression in the return
* statement of a constexpr function to have assert() and constexpr at the
* same time. It first uses assert for the condition given by the first argument
* and then returns the value of the second argument.
*
* \ingroup CxxUtilities
*/
* The macro DUNE_ASSERT_AND_RETURN can be used as expression in the return
* statement of a constexpr function to have assert() and constexpr at the
* same time. It first uses assert for the condition given by the first argument
* and then returns the value of the second argument.
*
* \ingroup CxxUtilities
*/
#ifdef NDEBUG
#define DUNE_ASSERT_AND_RETURN(C,X) X
#define DUNE_ASSERT_AND_RETURN(C,X) X
#else
#define DUNE_ASSERT_AND_RETURN(C,X) (!(C) ? throw [&](){assert(!#C);return 0;}() : 0), X
#define DUNE_ASSERT_AND_RETURN(C,X) (!(C) ? throw [&](){assert(!#C);return 0;}() : 0), X
#endif
......
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
/** @file
@author Robert Kloefkorn
@brief Provides check for implementation of interface methods when using
static polymorphism, i.e. the Barton-Nackman trick. This is purely for
debugging purposes. To check the correct implementation of interface methods
(and pick up possible infinite loops) NDEBUG must be undefined and
DUNE_INTERFACECHECK has to be defined.
@author Robert Kloefkorn
@brief Provides check for implementation of interface methods when using
static polymorphism, i.e. the Barton-Nackman trick. This is purely for
debugging purposes. To check the correct implementation of interface methods
(and pick up possible infinite loops) NDEBUG must be undefined and
DUNE_INTERFACECHECK has to be defined.
Use by invoking CHECK_INTERFACE_IMPLEMENTATION(asImp().methodToCheck())
and for
template methods double (CHECK_INTERFACE_IMPLEMENTATION((asImp().template methodToCheck<param> ())).
If either NDEBUG is defined or
DUNE_INTERFACECHECK is undefined the CHECK_INTERFACE_IMPLEMENTATION macro is empty.
Use by invoking CHECK_INTERFACE_IMPLEMENTATION(asImp().methodToCheck())
and for
template methods double (CHECK_INTERFACE_IMPLEMENTATION((asImp().template methodToCheck<param> ())).
If either NDEBUG is defined or
DUNE_INTERFACECHECK is undefined the CHECK_INTERFACE_IMPLEMENTATION macro is empty.
Note: adding the interface check to a method will cause the implementation of the
method to be called twice, so before use make sure
that this will not cause problems e.g. if internal counters are updated.
**/
Note: adding the interface check to a method will cause the implementation of the
method to be called twice, so before use make sure
that this will not cause problems e.g. if internal counters are updated.
**/
//- Dune includes
#include <dune/common/exceptions.hh>
......@@ -33,32 +33,32 @@ that this will not cause problems e.g. if internal counters are updated.
#define CHECK_INTERFACE_IMPLEMENTATION(dummy)
#else
#define CHECK_INTERFACE_IMPLEMENTATION(__interface_method_to_call__) \
{\
static bool call = false; \
if( call == true ) \
DUNE_THROW(NotImplemented,"Interface method not implemented!");\
call = true; \
try { \
(__interface_method_to_call__); \
call = false; \
} \
catch ( ... ) \
{ \
call = false; \
throw; \
} \
}
{\
static bool call = false; \
if( call == true ) \
DUNE_THROW(NotImplemented,"Interface method not implemented!");\
call = true; \
try { \
(__interface_method_to_call__); \
call = false; \
} \
catch ( ... ) \
{ \
call = false; \
throw; \
} \
}
#endif
/** The macro CHECK_AND_CALL_INTERFACE_IMPLEMENTATION throws an exception,
if the interface method ist not implemented and just calls the method
otherwise. If NDEBUG is defined no
checking is done and the method is just called.
*/
if the interface method ist not implemented and just calls the method
otherwise. If NDEBUG is defined no
checking is done and the method is just called.
*/
#if defined NDEBUG || !defined DUNE_INTERFACECHECK
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__) \
(__interface_method_to_call__)
(__interface_method_to_call__)
#else
#define CHECK_AND_CALL_INTERFACE_IMPLEMENTATION(__interface_method_to_call__) \
CHECK_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
CHECK_INTERFACE_IMPLEMENTATION(__interface_method_to_call__)
#endif
This diff is collapsed.
......@@ -5,44 +5,44 @@
#include <dune/internal/dune-common.hh>
/** \file
* \brief helper classes to provide unique types for standard functions
*/
* \brief helper classes to provide unique types for standard functions
*/
#include <algorithm>
namespace Dune
{
template<typename Type>
struct Min
{
using first_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
template<typename Type>
struct Min
{
using first_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
using second_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
using second_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
Type operator()(const Type& t1, const Type& t2) const
{
using std::min;
return min(t1,t2);
}
};
Type operator()(const Type& t1, const Type& t2) const
{
using std::min;
return min(t1,t2);
}
};
template<typename Type>
struct Max
{
using first_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
template<typename Type>
struct Max
{
using first_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
using second_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
using second_argument_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
using result_type [[deprecated("This type alias is deprecated following similar deprecations in C++17")]] = Type;
Type operator()(const Type& t1, const Type& t2) const
{
using std::max;
return max(t1,t2);
}
};
Type operator()(const Type& t1, const Type& t2) const
{
using std::max;
return max(t1,t2);
}
};
}
#endif
This diff is collapsed.
......@@ -5,32 +5,32 @@
#include <dune/common/exceptions.hh>
/**
* \file
* \brief Macro for wrapping boundary checks
*/
* \file
* \brief Macro for wrapping boundary checks
*/
/**
* @addtogroup Common
*
* @{
*/
* @addtogroup Common
*
* @{
*/
#ifndef DUNE_ASSERT_BOUNDS
#if defined(DUNE_CHECK_BOUNDS) || defined(DOXYGEN)
/**
* \brief If `DUNE_CHECK_BOUNDS` is defined: check if condition
* \a cond holds; otherwise, do nothing.
*
* Meant to be used for conditions that assure writes and reads
* do not occur outside of memory limits or pre-defined patterns
* and related conditions.
*/
* \brief If `DUNE_CHECK_BOUNDS` is defined: check if condition
* \a cond holds; otherwise, do nothing.
*
* Meant to be used for conditions that assure writes and reads
* do not occur outside of memory limits or pre-defined patterns
* and related conditions.
*/
#define DUNE_ASSERT_BOUNDS(cond) \
do { \
if (!(cond)) \
DUNE_THROW(Dune::RangeError, "Index out of bounds."); \
} while (false)
do { \
if (!(cond)) \
DUNE_THROW(Dune::RangeError, "Index out of bounds."); \
} while (false)
#else
#define DUNE_ASSERT_BOUNDS(cond)
......
......@@ -5,9 +5,9 @@
#include <dune/internal/dune-common.hh>
/** \file
* \brief A free function to provide the demangled class name
* of a given object or type as a string
*/
* \brief A free function to provide the demangled class name
* of a given object or type as a string
*/
#include <cstdlib>
#include <memory>
......@@ -21,57 +21,57 @@
namespace Dune {
namespace Impl {
namespace Impl {
inline std::string demangle(std::string name)
{
inline std::string demangle(std::string name)
{
#if HAVE_CXA_DEMANGLE
int status;
std::unique_ptr<char, void(*)(void*)>
demangled(abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status),
std::free);
if( demangled )
name = demangled.get();
int status;
std::unique_ptr<char, void(*)(void*)>
demangled(abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status),
std::free);
if( demangled )
name = demangled.get();
#endif // #if HAVE_CXA_DEMANGLE
return name;
}
}
return name;
}
}
/** \brief Provide the demangled class name of a type T as a string */
/*
* \ingroup CxxUtilities
*/
template <class T>
std::string className ()
{
typedef typename std::remove_reference<T>::type TR;
std::string className = Impl::demangle( typeid( TR ).name() );
if (std::is_const<TR>::value)
className += " const";
if (std::is_volatile<TR>::value)
className += " volatile";
if (std::is_lvalue_reference<T>::value)
className += "&";
else if (std::is_rvalue_reference<T>::value)
className += "&&";
return className;
}
/** \brief Provide the demangled class name of a type T as a string */
/*
* \ingroup CxxUtilities
*/
template <class T>
std::string className ()
{
typedef typename std::remove_reference<T>::type TR;
std::string className = Impl::demangle( typeid( TR ).name() );
if (std::is_const<TR>::value)
className += " const";
if (std::is_volatile<TR>::value)
className += " volatile";
if (std::is_lvalue_reference<T>::value)
className += "&";
else if (std::is_rvalue_reference<T>::value)
className += "&&";
return className;
}
/** \brief Provide the demangled class name of a given object as a string */
/*
* \ingroup CxxUtilities
*/
template <class T>
std::string className ( T&& v)
{
typedef typename std::remove_reference<T>::type TR;
std::string className = Impl::demangle( typeid(v).name() );
if (std::is_const<TR>::value)
className += " const";
if (std::is_volatile<TR>::value)
className += " volatile";
return className;
}
/** \brief Provide the demangled class name of a given object as a string */
/*
* \ingroup CxxUtilities
*/
template <class T>
std::string className ( T&& v)
{
typedef typename std::remove_reference<T>::type TR;
std::string className = Impl::demangle( typeid(v).name() );
if (std::is_const<TR>::value)
className += " const";
if (std::is_volatile<TR>::value)
className += " volatile";
return className;
}
} // namespace Dune
#endif // DUNE_CLASSNAME_HH
......@@ -14,44 +14,44 @@
#include <dune/common/std/type_traits.hh>
/**
* \file
*
* \brief Infrastructure for concepts.
*/
* \file
*
* \brief Infrastructure for concepts.
*/
namespace Dune {
/**
* \brief Namespace for concepts
*
* This namespace contains helper functions for
* concept definitions and the concept definitions
* themselves.
*
* \ingroup CxxConcepts
*/
* \brief Namespace for concepts
*
* This namespace contains helper functions for
* concept definitions and the concept definitions
* themselves.
*
* \ingroup CxxConcepts
*/
namespace Concept {
/**
* \brief Base class for refined concepts.
*
* If a new concept should refine one or more existing concepts,
* this can be achieved by deriving the new concept from
* Refines<C1,...,CN> where C1, ..., CN are the concepts
* to be refined. If you want to refine several concepts
* they should all be put in a single Refines<...> base
* class.
*
* \tparam BaseConcepts The list of concepts to be refined.
*
* \ingroup CxxConcepts
*/
* \brief Base class for refined concepts.
*
* If a new concept should refine one or more existing concepts,
* this can be achieved by deriving the new concept from
* Refines<C1,...,CN> where C1, ..., CN are the concepts
* to be refined. If you want to refine several concepts
* they should all be put in a single Refines<...> base
* class.
*
* \tparam BaseConcepts The list of concepts to be refined.
*
* \ingroup CxxConcepts
*/
template<class... BaseConcepts>
struct Refines
{
typedef TypeList<BaseConcepts...> BaseConceptList;
typedef TypeList<BaseConcepts...> BaseConceptList;
};
......@@ -59,88 +59,88 @@ typedef TypeList<BaseConcepts...> BaseConceptList;
namespace Impl {
// #############################################################################
// # All functions following here are implementation details
// # for the models() function below.
// #############################################################################
// Forward declaration
template<class C, class... T>
constexpr bool models();
// Here is the implementation of the concept checking.
// The first two overloads do the magic for checking
// if the requirements of a concept are satisfied.
// The rest is just for checking base concepts in case
// of refinement.
// This overload is present if type substitution for
// C::require(T...) is successful, i.e., if the T...
// matches the requirement of C. In this case this
// overload is selected because PriorityTag<1>
// is a better match for PrioriryTag<42> than
// PriorityTag<0> in the default overload.
template<class C, class... T,
decltype(std::declval<C>().require(std::declval<T>()...), 0) =0>
constexpr std::true_type matchesRequirement(PriorityTag<1>)
{ return {}; }
// If the above overload is ruled out by SFINAE because
// the T... does not match the requirements of C, then
// this default overload drops in.
template<class C, class... T>
constexpr std::false_type matchesRequirement(PriorityTag<0>)
{ return {}; }
// An empty list C of concepts is always matched by T...
template<class...T>
constexpr bool modelsConceptList(TypeList<>)
{ return true; }
// A nonempty list C0,..,CN of concepts is modeled
// by T... if it models the concept C0
// and all concepts in the list C1,..,CN.
template<class...T, class C0, class... CC>
constexpr bool modelsConceptList(TypeList<C0, CC...>)
{ return models<C0, T...>() and modelsConceptList<T...>(TypeList<CC...>()); }
// If C is an unrefined concept, then T... models C
// if it matches the requirement of C.
template<class C, class... T>
constexpr bool modelsConcept(PriorityTag<0>)
{ return matchesRequirement<C, T...>(PriorityTag<42>()); }
// If C is a refined concept, then T... models C
// if it matches the requirement of C and of
// all base concepts.
//
// This overload is used if C::BaseConceptList exists
// due to its higher priority.
template<class C, class... T,
decltype(typename C::BaseConceptList(), 0) = 0>
constexpr bool modelsConcept(PriorityTag<1>)
{ return matchesRequirement<C, T...>(PriorityTag<42>()) and modelsConceptList<T...>(typename C::BaseConceptList()); }
// This is the full concept check. It's defined here in the
// implementation namespace with 'constexpr bool' return type
// because we need a forward declaration in order to use it
// internally above.
//
// The actual interface function can then call this one and
// return the result as std::integral_constant<bool,*> which
// does not allow for a forward declaration because the return
// type is deduced.
template<class C, class... T>
constexpr bool models()
{
return modelsConcept<C, T...>(PriorityTag<42>());
}
// #############################################################################
// # All functions following here are implementation details
// # for the models() function below.
// #############################################################################
// Forward declaration
template<class C, class... T>
constexpr bool models();
// Here is the implementation of the concept checking.
// The first two overloads do the magic for checking
// if the requirements of a concept are satisfied.
// The rest is just for checking base concepts in case
// of refinement.
// This overload is present if type substitution for
// C::require(T...) is successful, i.e., if the T...
// matches the requirement of C. In this case this
// overload is selected because PriorityTag<1>
// is a better match for PrioriryTag<42> than
// PriorityTag<0> in the default overload.
template<class C, class... T,
decltype(std::declval<C>().require(std::declval<T>()...), 0) =0>
constexpr std::true_type matchesRequirement(PriorityTag<1>)
{ return {}; }
// If the above overload is ruled out by SFINAE because
// the T... does not match the requirements of C, then
// this default overload drops in.
template<class C, class... T>
constexpr std::false_type matchesRequirement(PriorityTag<0>)
{ return {}; }
// An empty list C of concepts is always matched by T...
template<class...T>
constexpr bool modelsConceptList(TypeList<>)
{ return true; }
// A nonempty list C0,..,CN of concepts is modeled
// by T... if it models the concept C0
// and all concepts in the list C1,..,CN.
template<class...T, class C0, class... CC>
constexpr bool modelsConceptList(TypeList<C0, CC...>)
{ return models<C0, T...>() and modelsConceptList<T...>(TypeList<CC...>()); }
// If C is an unrefined concept, then T... models C
// if it matches the requirement of C.
template<class C, class... T>
constexpr bool modelsConcept(PriorityTag<0>)
{ return matchesRequirement<C, T...>(PriorityTag<42>()); }
// If C is a refined concept, then T... models C
// if it matches the requirement of C and of
// all base concepts.
//
// This overload is used if C::BaseConceptList exists
// due to its higher priority.
template<class C, class... T,
decltype(typename C::BaseConceptList(), 0) = 0>
constexpr bool modelsConcept(PriorityTag<1>)
{ return matchesRequirement<C, T...>(PriorityTag<42>()) and modelsConceptList<T...>(typename C::BaseConceptList()); }
// This is the full concept check. It's defined here in the
// implementation namespace with 'constexpr bool' return type
// because we need a forward declaration in order to use it
// internally above.
//
// The actual interface function can then call this one and
// return the result as std::integral_constant<bool,*> which
// does not allow for a forward declaration because the return
// type is deduced.
template<class C, class... T>
constexpr bool models()
{
return modelsConcept<C, T...>(PriorityTag<42>());
}
} // namespace Dune::Concept::Impl
......@@ -151,38 +151,38 @@ return modelsConcept<C, T...>(PriorityTag<42>());
/**
* \brief Check if concept is modeled by given types
*
* This will check if the given concept is modeled by the given
* list of types. This is true if the list of types models all
* the base concepts that are refined by the given concept
* and if it satisfies all additional requirements of the latter.
*
* Notice that a concept may be defined for a list of interacting types.
* The function will check if the given list of types matches the requirements
* on the whole list. It does not check if each individual type in the list
* satisfies the concept.
*
* This concept check mechanism is inspired by the concept checking
* facility in Eric Nieblers range-v3. For more information please
* refer to the libraries project page https://github.com/ericniebler/range-v3
* or this blog entry: http://ericniebler.com/2013/11/23/concept-checking-in-c11.
* In fact the interface provided here is almost exactly the same as in range-v3.
* However the implementation differs, because range-v3 uses its own meta-programming
* library whereas our implementation is more straight forward.
*
* The result is returned as std::integral_constant<bool, ...> which
* allows to nicely use this method with Hybrid::ifElse.
*
* \tparam C The concept to check
* \tparam T The list of type to check against the concept
*
* \ingroup CxxConcepts
*/
* \brief Check if concept is modeled by given types
*
* This will check if the given concept is modeled by the given
* list of types. This is true if the list of types models all
* the base concepts that are refined by the given concept
* and if it satisfies all additional requirements of the latter.
*
* Notice that a concept may be defined for a list of interacting types.
* The function will check if the given list of types matches the requirements
* on the whole list. It does not check if each individual type in the list
* satisfies the concept.
*
* This concept check mechanism is inspired by the concept checking
* facility in Eric Nieblers range-v3. For more information please
* refer to the libraries project page https://github.com/ericniebler/range-v3
* or this blog entry: http://ericniebler.com/2013/11/23/concept-checking-in-c11.
* In fact the interface provided here is almost exactly the same as in range-v3.
* However the implementation differs, because range-v3 uses its own meta-programming
* library whereas our implementation is more straight forward.
*
* The result is returned as std::integral_constant<bool, ...> which
* allows to nicely use this method with Hybrid::ifElse.
*
* \tparam C The concept to check
* \tparam T The list of type to check against the concept
*
* \ingroup CxxConcepts
*/
template<class C, class... T>
constexpr auto models()
{
return Std::bool_constant<Concept::Impl::models<C, T...>()>();
return Std::bool_constant<Concept::Impl::models<C, T...>()>();
}
......@@ -193,21 +193,21 @@ namespace Concept {
namespace Impl {
// #############################################################################
// # All functions following here are implementation details for the
// # for the tupleEntriesModel() function below.
// #############################################################################
template<class C, class Tuple>
struct TupleEntriesModelHelper
{
template<class Accumulated, class T>
struct AccumulateFunctor
{
using type = typename std::integral_constant<bool, Accumulated::value and models<C, T>()>;
};
using Result = typename ReduceTuple<AccumulateFunctor, Tuple, std::true_type>::type;
};
// #############################################################################
// # All functions following here are implementation details for the
// # for the tupleEntriesModel() function below.
// #############################################################################
template<class C, class Tuple>
struct TupleEntriesModelHelper
{
template<class Accumulated, class T>
struct AccumulateFunctor
{
using type = typename std::integral_constant<bool, Accumulated::value and models<C, T>()>;
};
using Result = typename ReduceTuple<AccumulateFunctor, Tuple, std::true_type>::type;
};
} // namespace Dune::Concept::Impl
......@@ -221,9 +221,9 @@ using Result = typename ReduceTuple<AccumulateFunctor, Tuple, std::true_type>::t
template<class C, class Tuple>
constexpr auto tupleEntriesModel()
-> typename Impl::TupleEntriesModelHelper<C, Tuple>::Result
-> typename Impl::TupleEntriesModelHelper<C, Tuple>::Result
{
return {};
return {};
}
// #############################################################################
......@@ -237,14 +237,14 @@ return {};
template<bool b, typename std::enable_if<b, int>::type = 0>
constexpr bool requireTrue()
{
return true;
return true;
}
// Helper function for use in concept definitions.
template<class C, class... T, typename std::enable_if<models<C, T...>(), int>::type = 0>
constexpr bool requireConcept()
{
return true;
return true;
}
// Helper function for use in concept definitions.
......@@ -252,7 +252,7 @@ return true;
template<class C, class... T, typename std::enable_if<models<C, T...>(), int>::type = 0>
constexpr bool requireConcept(T&&... /*t*/)
{
return true;
return true;
}
// Helper function for use in concept definitions.
......@@ -260,25 +260,25 @@ return true;
template<class C, class Tuple, typename std::enable_if<tupleEntriesModel<C, Tuple>(), int>::type = 0>
constexpr bool requireConceptForTupleEntries()
{
return true;
return true;
}
// Helper function for use in concept definitions.
// If the first passed type is not convertible to the second, the concept will not be satisfied.
template<class From, class To,
typename std::enable_if< std::is_convertible<From, To>::value, int>::type = 0>
typename std::enable_if< std::is_convertible<From, To>::value, int>::type = 0>
constexpr bool requireConvertible()
{
return true;
return true;
}
// Helper function for use in concept definitions.
// If passed argument is not convertible to the first passed type, the concept will not be satisfied.
template<class To, class From,
typename std::enable_if< std::is_convertible<From, To>::value, int>::type = 0>
typename std::enable_if< std::is_convertible<From, To>::value, int>::type = 0>
constexpr bool requireConvertible(const From&)
{
return true;
return true;
}
// Helper function for use in concept definitions.
......@@ -288,41 +288,41 @@ return true;
template<typename T>
constexpr bool requireType()
{
return true;
return true;
}
// Helper function for use in concept definitions.
// If first passed type is not a base class of second type, the concept will not be satisfied.
template<class Base, class Derived,
typename std::enable_if< std::is_base_of<Base, Derived>::value, int>::type = 0>
typename std::enable_if< std::is_base_of<Base, Derived>::value, int>::type = 0>
constexpr bool requireBaseOf()
{
return true;
return true;
}
// Helper function for use in concept definitions.
// If first passed type is not a base class of first arguments type, the concept will not be satisfied.
template<class Base, class Derived,
typename std::enable_if< std::is_base_of<Base, Derived>::value, int>::type = 0>
typename std::enable_if< std::is_base_of<Base, Derived>::value, int>::type = 0>
constexpr bool requireBaseOf(const Derived&)
{
return true;
return true;
}
// Helper function for use in concept definitions.
// If the passed types are not the same, the concept will not be satisfied.
template<class A, class B,
typename std::enable_if< std::is_same<A, B>::value, int>::type = 0>
typename std::enable_if< std::is_same<A, B>::value, int>::type = 0>
constexpr bool requireSameType()
{
return true;
return true;
}
} // namespace Dune::Concept
/** @} */
/** @} */
} // namespace Dune
......
......@@ -5,29 +5,29 @@
namespace Dune
{
/** \brief conditional evaluate
sometimes call immediate if, evaluates to
\code
if (b)
return v1;
else
return v2;
\endcode
In contrast to if-then-else the cond function can also be
evaluated for vector valued SIMD data types, see simd.hh.
\param b boolean value
\param v1 value of b==true
\param v2 value of b==false
*/
template<typename T1, typename T2>
const T1 cond(bool b, const T1 & v1, const T2 & v2)
{
return (b ? v1 : v2);
}
/** \brief conditional evaluate
sometimes call immediate if, evaluates to
\code
if (b)
return v1;
else
return v2;
\endcode
In contrast to if-then-else the cond function can also be
evaluated for vector valued SIMD data types, see simd.hh.
\param b boolean value
\param v1 value of b==true
\param v2 value of b==false
*/
template<typename T1, typename T2>
const T1 cond(bool b, const T1 & v1, const T2 & v2)
{
return (b ? v1 : v2);
}
} // end namespace Dune
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment