Skip to content

Instantly share code, notes, and snippets.

@loliGothicK
Created April 12, 2018 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loliGothicK/39cb3f21bcac603a9ecb227c3715b36c to your computer and use it in GitHub Desktop.
Save loliGothicK/39cb3f21bcac603a9ecb227c3715b36c to your computer and use it in GitHub Desktop.
#include <limits>
#include <utility>
template < class T >
constexpr
decltype(std::declval<T>()*2)
twice(T a) {
return a*2;
}
static_assert([]{
for(int i{0}; i < 1'000'000; ++i)
if ( twice(i) != i*2 ) return false;
return true;
}());
int main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment