]>
Dogcows Code - chaz/yoink/blob - src/Moof/cml/core/meta/common.h
1 /* -*- C++ -*- ------------------------------------------------------------
3 Copyright (c) 2007 Jesse Anders and Demian Nave http://cmldev.net/
5 The Configurable Math Library (CML) is distributed under the terms of the
6 Boost Software License, v1.0 (see cml/LICENSE for details).
8 *-----------------------------------------------------------------------*/
13 #ifndef core_meta_common_h
14 #define core_meta_common_h
18 /** Type of a true statement. */
21 /** Type of a false statement. */
24 template<bool B
> struct is_true
{
25 typedef false_type result
;
28 template<> struct is_true
<true> {
29 typedef true_type result
;
33 template<typename T1
, typename T2
> struct type_pair
{
38 /** A "type quadruple". */
39 template<typename T1
, typename T2
, typename T3
, typename T4
>
47 /** Match any type (for use with same_type<> and select_switch<>). */
50 /** Determine if two types are the same.
54 template<typename T
, typename U
> struct same_type
{
55 typedef false_type result
;
56 enum { is_true
= false, is_false
= true };
59 /** Match the same type for both of same_type's template arguments. */
60 template<typename T
> struct same_type
<T
,T
> {
61 typedef true_type result
;
62 enum { is_true
= true, is_false
= false };
65 /** Match a type and any_type. */
66 template<typename T
> struct same_type
<T
,any_type
> {
67 typedef true_type result
;
68 enum { is_true
= true, is_false
= false };
71 /** Match a type and any_type. */
72 template<typename T
> struct same_type
<any_type
,T
> {
73 typedef true_type result
;
74 enum { is_true
= true, is_false
= false };
77 /** Disambiguate pair of any_type's. */
78 template<> struct same_type
<any_type
,any_type
> {
79 typedef true_type result
;
80 enum { is_true
= true, is_false
= false };
83 /** Remove a reference qualifier from a type. */
84 template<typename T
> struct remove_reference
{
85 template<typename Q
, typename Dummy
> struct helper
{
89 template<typename Q
> struct helper
<Q
&, void> {
93 template<typename Q
> struct helper
<const Q
&, void> {
97 typedef typename helper
<T
,void>::type type
;
100 /** Remove a const qualifier from a type. */
101 template<typename T
> struct remove_const
{
102 template<typename Q
, typename Dummy
> struct helper
{
106 template<typename Q
> struct helper
<const Q
, void> {
110 typedef typename helper
<T
,void>::type type
;
117 // -------------------------------------------------------------------------
This page took 0.042213 seconds and 5 git commands to generate.