cgv
Loading...
Searching...
No Matches
promote.h
1
#pragma once
2
3
#include <cgv/type/func/drop_const.h>
4
#include <cgv/type/func/make_const.h>
5
#include <cgv/type/ctrl/if_.h>
6
7
namespace
cgv
{
8
namespace
type {
9
namespace
func {
10
namespace
Promote {
12
template
<
typename
T>
struct
promotion_rank
{
enum
{ rank = 1000 }; };
13
template
<>
struct
promotion_rank
<bool> {
enum
{ rank = 0 }; };
14
template
<>
struct
promotion_rank
<char> {
enum
{ rank = 10 }; };
15
template
<>
struct
promotion_rank
<unsigned char> {
enum
{ rank = 20 }; };
16
template
<>
struct
promotion_rank
<short> {
enum
{ rank = 30 }; };
17
template
<>
struct
promotion_rank
<unsigned short> {
enum
{ rank = 40 }; };
18
template
<>
struct
promotion_rank
<int> {
enum
{ rank = 50 }; };
19
template
<>
struct
promotion_rank
<unsigned int> {
enum
{ rank = 60 }; };
20
template
<>
struct
promotion_rank
<long> {
enum
{ rank = 70 }; };
21
template
<>
struct
promotion_rank
<unsigned long> {
enum
{ rank = 80 }; };
22
template
<>
struct
promotion_rank
<float> {
enum
{ rank = 90 }; };
23
template
<>
struct
promotion_rank
<double> {
enum
{ rank = 100 }; };
24
}
26
template
<
typename
T1,
typename
T2>
27
struct
promote
28
{
29
static
const
bool
favour_first =
30
(
unsigned
int)
Promote::promotion_rank<T1>::rank
>(
unsigned
int
)
Promote::promotion_rank<T2>::rank
;
31
typedef
typename
ctrl::if_<favour_first, T1, T2>::type type;
32
};
33
template
<>
struct
promote
<int,float> {
typedef
double
type; };
34
template
<>
struct
promote
<float,int> {
typedef
double
type; };
35
template
<>
struct
promote
<unsigned int,float> {
typedef
double
type; };
36
template
<>
struct
promote
<float,unsigned int> {
typedef
double
type; };
37
template
<>
struct
promote
<long,float> {
typedef
double
type; };
38
template
<>
struct
promote
<float,long> {
typedef
double
type; };
39
template
<>
struct
promote
<unsigned long,float> {
typedef
double
type; };
40
template
<>
struct
promote
<float,unsigned long> {
typedef
double
type; };
41
}
42
}
43
}
cgv
the cgv namespace
Definition
print.h:11
cgv::type::func::Promote::promotion_rank
the promote rank template defines a rank for each type which is used to automatically detect the prom...
Definition
promote.h:12
cgv::type::func::promote
determine the type that should be used to represent the result of an operator or function applies to ...
Definition
promote.h:28
cgv
type
func
promote.h
Generated by
1.9.8