ComputationalRadiationPhysics / graybat

Graph Approach for Highly Generic Communication Schemes Based on Adaptive Topologies :satellite:
Other
8 stars 4 forks source link

Add concepts support #118

Open erikzenker opened 7 years ago

erikzenker commented 7 years ago

Provide concept definitions for CommunicationPolicy, GraphPolicy, Context, Data. Modern compilers such as gcc 6.x can process concept definitions with -fconcepts.

erikzenker commented 7 years ago

As a first step I will describe the concepts as text comments and annotate the code with them e.g.:

// T models concept::Container
template<typename T>
void foo(T t)
{
}
theZiz commented 7 years ago

Is there a nice way to define concepts if they are supported, but to ignore them if not? Without using preprocessor cheks?

erikzenker commented 7 years ago

Well, I don`t think so, because if they are not implemented by the compiler then a concept is an unknown keyword. But I think a simple macro is okay e.g.:

template<typename T>
GRAYBAT_ENABLE_CONCEPTS(requires SomeConcept<T>)
void foo(T t)
{
}
fabian-jung commented 7 years ago

I think you could add preprocessor guards, that check for a specific compiler and therefore for concept support. But it's questionable if that is worth the hassle.

theZiz commented 7 years ago

@fabian-jung: Of course. But nobody wants compiler check preprocessor magic in C++ Code in the year 2016. I guess the macro idea is better, which is basically the same, but only once and hidden. ;)

bussmann commented 7 years ago

The CPP core guidelines have this to say: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-emulate

erikzenker commented 7 years ago

Well, yes you can use template metaprogramming to achieve something similar.

erikzenker commented 7 years ago

As I first step I collected concepts and started to describe them in a "concept like" way in #129.