Skip to content

Instantly share code, notes, and snippets.

@Bigpet
Created December 4, 2015 08:16
Show Gist options
  • Save Bigpet/7269ebac58b3d34f7b8d to your computer and use it in GitHub Desktop.
Save Bigpet/7269ebac58b3d34f7b8d to your computer and use it in GitHub Desktop.
VS is trolling me
#include <type_traits>
#include <iostream>
#include <array>
template<typename T>
auto func(const T& t) -> typename std::common_type<float, T>::type
{
return 5.0f + t;
}
float func(const std::array<float,3>& t)
{
return 5.0f + t[0];
}
int test()
{
std::array<float,3> c{ {1,2,3} };
auto b = func(5);
auto d = func(c);
std::cout << b << std::endl;
std::cout << d << std::endl;
}
int main()
{
test();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment