Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
Main Page
Related Pages
Topics
Namespaces
Data Structures
Files
File List
Globals
EXTERNAL_HEADERS
RSL
etc
config
src
ABS_OVERLOADS.cpp
Go to the documentation of this file.
1
// checking for overloads of abs()
2
3
25
// determine whether the abs() function (including
26
// any overloads) is defined in the usual libc headers
27
28
#include <
math.h
>
29
#include <
stdio.h
>
30
#include <
stdlib.h
>
31
32
#include "config.h"
33
34
#ifndef _RWSTD_NO_LONG_LONG
35
# if defined _MSC_VER
36
# define LONG_LONG __int64
37
# else
38
# define LONG_LONG long long
39
# endif
40
#endif
// _RWSTD_NO_LONG_LONG
41
42
43
int
template_used
;
44
45
template
<
class
T>
46
T
abs
(
T
t
)
47
{
48
++
template_used
;
49
50
return
t
;
51
}
52
53
template
<
class
T>
54
void
check_abs
(
T
t
,
const
char
*tname)
55
{
56
template_used
= 0;
57
58
abs
(
t
);
59
60
if
(0 ==
template_used
)
61
printf
(
"%s"
,
"// "
);
62
63
printf
(
"#define _RWSTD_NO_ABS_%s\n"
, tname);
64
}
65
66
int
main
()
67
{
68
check_abs
((
bool
)0,
"BOOL"
);
69
check_abs
((
char
)0,
"CHAR"
);
70
check_abs
((
signed
char
)0,
"SCHAR"
);
71
check_abs
((
unsigned
char
)0,
"UCHAR"
);
72
check_abs
((
short
)0,
"SHRT"
);
73
check_abs
((
unsigned
short
)0,
"USHRT"
);
74
check_abs
((
int
)0,
"INT"
);
75
check_abs
((
unsigned
)0,
"UINT"
);
76
check_abs
((
long
)0,
"LONG"
);
77
check_abs
((
unsigned
long
)0,
"ULONG"
);
78
79
#if defined (LONG_LONG)
80
check_abs
((
LONG_LONG
)0,
"LLONG"
);
81
check_abs
((
unsigned
LONG_LONG
)0,
"ULLONG"
);
82
#endif
// LONG_LONG
83
84
return
0;
85
}
T
#define T
Definition
17.names.cpp:163
t
#define t
Definition
17.names.cpp:136
abs
T abs(T t)
Definition
ABS_OVERLOADS.cpp:46
check_abs
void check_abs(T t, const char *tname)
Definition
ABS_OVERLOADS.cpp:54
main
int main()
Definition
ABS_OVERLOADS.cpp:66
LONG_LONG
#define LONG_LONG
Definition
ABS_OVERLOADS.cpp:38
template_used
int template_used
Definition
ABS_OVERLOADS.cpp:43
printf
IMPORT_C SInt32 printf(const Char *,...)
math.h
stdio.h
stdlib.h
Generated by
1.9.8