Last active
December 16, 2015 09:28
-
-
Save klmr/5412724 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 Source> | |
struct auto_cast_helper { | |
Source const& value; | |
explicit auto_cast_helper(Source const& value) : value(value) { } | |
template <typename Target> | |
operator Target() const { | |
return static_cast<Target>(value); | |
} | |
}; | |
template <typename Source> | |
auto_cast_helper<Source> auto_cast(Source const& value) { | |
return auto_cast_helper<Source>(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment