Created
June 18, 2020 10:00
-
-
Save AndrewLipscomb/4650f9ae75f27e5e81c8fc3f8e693b44 to your computer and use it in GitHub Desktop.
minimal c++ for https://stackoverflow.com/questions/62447159/mixing-templates-with-stdenable-if-t-and-specialisation
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
#include <string> | |
#include <type_traits> | |
template<typename T, typename R> | |
R do_foo(T bb) | |
{ | |
static_assert(std::is_same<T, void>::value && false, "No use here"); | |
} | |
template<typename T, typename R> | |
std::enable_if_t<std::is_same<R, std::string>::value, R> do_foo(T bb) | |
{ | |
return "Boots"; | |
} | |
template<> | |
bool do_foo(int bb) | |
{ | |
return false; | |
} | |
int main() | |
{ | |
do_foo<std::string, std::string>(std::string()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment