Created
February 18, 2018 00:59
-
-
Save loliGothicK/e10be08f8eb43af910c6e5d23eb69b2a to your computer and use it in GitHub Desktop.
contexpr lambdaが一行で表現できないconstexpr variable templateの定義に使えそうとういうアレ
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<template <class> class Pred, typename ...Types> | |
constexpr inline std::size_t type_find_if = [] | |
{ | |
size_t result{}; | |
for(bool b: {Pred<Types>::value...}) if(b) return result; else ++result; | |
return sizeof...(Types); | |
}(); | |
int main() { | |
static_assert(type_find_if<std::is_unsigned, int, char, short, int, unsigned,long> == 4); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment