Skip to content

Instantly share code, notes, and snippets.

@FuZer
Last active February 17, 2019 22:40
Show Gist options
  • Select an option

  • Save FuZer/2d7dc665572f1238737f9e5fa70d99df to your computer and use it in GitHub Desktop.

Select an option

Save FuZer/2d7dc665572f1238737f9e5fa70d99df to your computer and use it in GitHub Desktop.
A<0> 제거, 재귀적 접근 다이렉트로 접근하게 변경, 잘못된 접근 컴파일 에러
#include <iostream>
template <std::size_t Idx>
struct A {
constexpr static std::size_t idx = Idx;
template <std::size_t Target>
using get = std::enable_if_t<(Idx > Target), std::conditional_t<Target == 0, A<Idx>, A<Idx-Target>>>;
};
int main() {
std::cout << A<1000>::get<100>::idx << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment