Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Leibner
dune-common
Commits
fda5a9e0
Commit
fda5a9e0
authored
10 years ago
by
Christoph Grüninger
Browse files
Options
Downloads
Patches
Plain Diff
[cleanup] Remove fall-back code for type_traits.
Maybe we can deprecate the complete header type_traits.hh.
parent
ac1f2dc8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dune/common/alignment.hh
+1
-10
1 addition, 10 deletions
dune/common/alignment.hh
dune/common/typetraits.hh
+1
-111
1 addition, 111 deletions
dune/common/typetraits.hh
with
2 additions
and
121 deletions
dune/common/alignment.hh
+
1
−
10
View file @
fda5a9e0
...
...
@@ -3,12 +3,9 @@
// $Id$
#ifndef DUNE_ALIGNMENT_HH
#define DUNE_ALIGNMENT_HH
#include
<cstddef>
#if HAVE_TYPE_TRAITS
#include
<type_traits>
#elif HAVE_TR1_TYPE_TRAITS
#include
<tr1/type_traits>
#endif
namespace
Dune
{
...
...
@@ -102,13 +99,7 @@ namespace Dune
enum
{
/** @brief The alignment requirement. */
#ifdef HAVE_TYPE_TRAITS
value
=
std
::
alignment_of
<
T
>::
value
#elif HAVE_TR1_TYPETRAITS
value
=
std
::
tr1
::
alignment_of
<
T
>::
value
#else
value
=
AlignmentTester
<
T
,
sizeof
(
AlignmentStruct
<
T
>
)
-
sizeof
(
T
)
-
1
>::
result
#endif
};
};
...
...
This diff is collapsed.
Click to expand it.
dune/common/typetraits.hh
+
1
−
111
View file @
fda5a9e0
...
...
@@ -3,11 +3,7 @@
#ifndef DUNE_TYPETRAITS_HH
#define DUNE_TYPETRAITS_HH
#if defined HAVE_TYPE_TRAITS
#include
<type_traits>
#elif defined HAVE_TR1_TYPE_TRAITS
#include
<tr1/type_traits>
#endif
#include
<dune/common/deprecated.hh>
...
...
@@ -163,41 +159,8 @@ namespace Dune
typedef
volatile
typename
ConstantVolatileTraits
<
T
>::
UnqualifiedType
Type
;
};
#if defined HAVE_TYPE_TRAITS
using
std
::
remove_const
;
#elif defined HAVE_TR1_TYPE_TRAITS
using
std
::
tr1
::
remove_const
;
#else
/**
* @brief Removes a const qualifier while preserving others.
*/
template
<
typename
T
>
struct
remove_const
{
typedef
typename
RemoveConstHelper
<
T
,
IsVolatile
<
T
>::
value
>::
Type
type
;
};
#endif
#if defined HAVE_TYPE_TRAITS
using
std
::
remove_reference
;
#elif defined HAVE_TR1_TYPE_TRAITS
using
std
::
tr1
::
remove_reference
;
#else
//! Remove a reference from a type
/**
* If the template parameter \c T matches \c T1&, then the member typedef \c
* type is \c T1, otherwise it is \c T.
*/
template
<
typename
T
>
struct
remove_reference
{
//! T with references removed
typedef
T
type
;
};
# ifndef DOXYGEN
template
<
typename
T
>
struct
remove_reference
<
T
&>
{
typedef
T
type
;
};
# endif // ! defined(DOXYGEN)
#endif
/**
* @brief Checks wether a type is convertible to another.
...
...
@@ -315,26 +278,7 @@ namespace Dune
};
};
#ifdef HAVE_TYPE_TRAITS
using
std
::
enable_if
;
#else
/**
* @brief Enable typedef if condition is met.
*
* Replacement implementation for compilers without this in the stl.
* Depending on the value of b the type T is provided as typedef type.
*/
template
<
bool
b
,
typename
T
=
void
>
struct
enable_if
{
typedef
T
type
;
};
template
<
typename
T
>
struct
enable_if
<
false
,
T
>
{};
#endif
/**
* @brief Enable typedef if two types are interoperable.
...
...
@@ -346,67 +290,13 @@ namespace Dune
:
public
enable_if
<
IsInteroperable
<
T1
,
T2
>::
value
,
Type
>
{};
#if defined HAVE_TYPE_TRAITS
using
std
::
is_same
;
#elif defined HAVE_TR1_TYPE_TRAITS
using
std
::
tr1
::
is_same
;
#else
/**
* @brief Compile time test for testing whether
* two types are the same.
*/
template
<
typename
T1
,
typename
T2
>
struct
is_same
{
//! Whether T1 is the same type as T2.
enum
{
/* @brief Whether T1 is the same type as T2. */
value
=
false
};
};
template
<
typename
T
>
struct
is_same
<
T
,
T
>
{
enum
{
value
=
true
};
};
#endif
// pull in default implementation
using
std
::
is_same
;
using
std
::
conditional
;
////////////////////////////////////////////////////////////////////////
//
// integral_constant (C++0x 20.7.3 "Helper classes")
//
#if HAVE_INTEGRAL_CONSTANT
using
std
::
integral_constant
;
using
std
::
true_type
;
using
std
::
false_type
;
#else // #if HAVE_INTEGRAL_CONSTANT
//! Generate a type for a given integral constant
/**
* \tparam T Type of the constant.
* \tparam v Value of the constant.
*/
template
<
class
T
,
T
v
>
struct
integral_constant
{
//! value this type was generated for
static
const
T
value
=
v
;
//! type of value
typedef
T
value_type
;
//! type of this class itself
typedef
integral_constant
<
T
,
v
>
type
;
//! conversion to value_type/T
operator
value_type
()
{
return
value
;
}
};
//! type for true
typedef
integral_constant
<
bool
,
true
>
true_type
;
//! type for false
typedef
integral_constant
<
bool
,
false
>
false_type
;
#endif // #else // #if HAVE_INTEGRAL_CONSTANT
template
<
typename
>
struct
__is_pointer_helper
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment