Line | |
---|
1 | /*
|
---|
2 | * recast.h
|
---|
3 | *
|
---|
4 | * Created on: Jun 26, 2012
|
---|
5 | * Author: utke
|
---|
6 | */
|
---|
7 |
|
---|
8 | #ifndef _RECAST_H_
|
---|
9 | #define _RECAST_H_
|
---|
10 |
|
---|
11 | #ifdef HAVE_CONFIG_H
|
---|
12 | #include <config.h>
|
---|
13 | #else
|
---|
14 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
15 | #endif
|
---|
16 |
|
---|
17 | #if !defined(_HAVE_ADOLC_) || defined(_WRAPPERS_)
|
---|
18 |
|
---|
19 | template<class To, class From>
|
---|
20 | To reCast(const From& from) {
|
---|
21 | return (To)from;
|
---|
22 | }
|
---|
23 |
|
---|
24 | #else
|
---|
25 | #include "./types.h"
|
---|
26 |
|
---|
27 | template<class To, class From>
|
---|
28 | struct ForPartialSpecialization {
|
---|
29 | static To reCast(const From& from ) { return (To) from;}
|
---|
30 | };
|
---|
31 |
|
---|
32 | template<class To, class From>
|
---|
33 | To reCast(const From& from) {
|
---|
34 | return ForPartialSpecialization<To,From>::reCast(from);
|
---|
35 | }
|
---|
36 | /**
|
---|
37 | * partial specialization
|
---|
38 | */
|
---|
39 | template<class To>
|
---|
40 | struct ForPartialSpecialization<To,adouble> {
|
---|
41 | static To reCast(const adouble& from ) { return (To) (from.getValue());}
|
---|
42 | };
|
---|
43 |
|
---|
44 | #endif
|
---|
45 |
|
---|
46 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.