Last active
February 17, 2019 22:27
-
-
Save FuZer/8681b5be993963e19063b84e8a47a9b6 to your computer and use it in GitHub Desktop.
get Template 명시, enable_if_t 제거
This file contains hidden or 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
| #include <iostream> | |
| template <std::size_t Idx> | |
| struct A { | |
| constexpr static std::size_t idx = Idx; | |
| template <std::size_t Target> | |
| using get = std::conditional_t<Target == 0, A<Idx>, typename A<idx-1>::template get<Target-1>>; | |
| }; | |
| template <> | |
| struct A<0> { | |
| constexpr static std::size_t idx = 0; | |
| template <std::size_t Target> | |
| using get = A<0>; | |
| }; | |
| int main() { | |
| std::cout << A<10>::get<4>::idx << std::endl; // print 6 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
using get = A<0>;
이부분은 목적에 맞게 변경하면 될듯