Skip to content

Instantly share code, notes, and snippets.

@AndrewLipscomb
Created June 18, 2020 10:00
Show Gist options
  • Save AndrewLipscomb/4650f9ae75f27e5e81c8fc3f8e693b44 to your computer and use it in GitHub Desktop.
Save AndrewLipscomb/4650f9ae75f27e5e81c8fc3f8e693b44 to your computer and use it in GitHub Desktop.
#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