dune-common
2.2.1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
dune
common
static_assert.hh
Go to the documentation of this file.
1
// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2
// vi: set et ts=8 sw=2 sts=2:
3
#ifndef DUNE_STATIC_ASSERT_HH
4
#define DUNE_STATIC_ASSERT_HH
5
16
#if not HAVE_STATIC_ASSERT
17
// Taken from BOOST
18
//
19
// Helper macro CPPMAGIC_JOIN:
20
// The following piece of macro magic joins the two
21
// arguments together, even when one of the arguments is
22
// itself a macro (see 16.3.1 in C++ standard). The key
23
// is that macro expansion of macro arguments does not
24
// occur in CPPMAGIC_DO_JOIN2 but does in CPPMAGIC_DO_JOIN.
25
//
26
#define CPPMAGIC_JOIN( X, Y ) CPPMAGIC_DO_JOIN( X, Y )
27
#define CPPMAGIC_DO_JOIN( X, Y ) CPPMAGIC_DO_JOIN2(X,Y)
28
#define CPPMAGIC_DO_JOIN2( X, Y ) X##Y
29
30
template
<
bool
x>
struct
static_assert_failure;
31
32
template
<>
struct
static_assert_failure<true> { };
33
34
template
<
int
x>
struct
static_assert_test{};
35
#endif
36
75
#if HAVE_STATIC_ASSERT
76
#define dune_static_assert(COND,MSG) \
77
static_assert(COND,MSG)
78
#else
79
#define dune_static_assert(COND,MSG) \
80
typedef static_assert_test< \
81
sizeof(static_assert_failure< (bool)( COND )>)\
82
> CPPMAGIC_JOIN(dune_static_assert_typedef_, __LINE__)
83
#endif
84
85
namespace
Dune {
87
103
119
126
template
<
typename
T>
127
struct
AlwaysFalse
{
129
static
const
bool
value
=
false
;
130
};
131
133
139
template
<
typename
T>
140
struct
AlwaysTrue
{
142
static
const
bool
value
=
true
;
143
};
144
}
// namespace Dune
145
146
/* @} */
147
148
#endif
Generated on Tue Feb 26 2013 17:20:15 for dune-common by
1.8.1.2