Last change
on this file since 12583 was 12546, checked in by utke, 13 years ago |
add casting mechanism that makes the switch from double to adouble for IssmDouble transparent
|
File size:
676 bytes
|
Rev | Line | |
---|
[12546] | 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 | #ifndef _HAVE_ADOLC_
|
---|
| 12 |
|
---|
| 13 | template<class To, class From>
|
---|
| 14 | To reCast(const From& from) {
|
---|
| 15 | return (To)from;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | #else
|
---|
| 19 |
|
---|
| 20 | template<class To, class From>
|
---|
| 21 | struct ForPartialSpecialization {
|
---|
| 22 | static To reCast(const From& from ) { return (To) from;}
|
---|
| 23 | };
|
---|
| 24 |
|
---|
| 25 | template<class To, class From>
|
---|
| 26 | To reCast(const From& from) {
|
---|
| 27 | return ForPartialSpecialization<To,From>::reCast(from);
|
---|
| 28 | }
|
---|
| 29 | /**
|
---|
| 30 | * partial specialization
|
---|
| 31 | */
|
---|
| 32 | template<class To>
|
---|
| 33 | struct ForPartialSpecialization<To,adouble> {
|
---|
| 34 | static To reCast(const adouble& from ) { return (To) (from.getValue());}
|
---|
| 35 | };
|
---|
| 36 |
|
---|
| 37 | #endif
|
---|
| 38 |
|
---|
| 39 | #endif
|
---|
Note:
See
TracBrowser
for help on using the repository browser.