Created
October 3, 2014 21:06
-
-
Save tomjnixon/755a3095b8a1d6965ae5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T> | |
struct Foo { | |
T *x; | |
Foo(T *x) : x(x) {} | |
// operator Foo<const T> () const { return Foo<const T>(x); } | |
}; | |
template <typename T> | |
T func(Foo<const T> f, T *out) { | |
*out = *f.x; | |
} | |
template <typename T> | |
void wrapper(const T * const x, T *out) { | |
Foo<const T> f = {x}; | |
func(f, out); | |
} | |
void library() { | |
const double x = 5; | |
double out; | |
wrapper(&x, &out); | |
} | |
int main(int argc, char **argv) { | |
double x = 0.0; | |
Foo<double> f = {&x}; | |
double out; | |
func<double>(f, &out); | |
library(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment