Last active
August 10, 2017 11:09
-
-
Save griwes/e7a467d24e9f016c0d68 to your computer and use it in GitHub Desktop.
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
template<typename Type, typename Tag = class default_tag> | |
struct list_mixin | |
{ | |
Type * prev = nullptr; | |
Type * next = nullptr; | |
}; | |
template<typename CRTP, typename... Tags> | |
struct list_mixins : list_mixin<CRTP, Tags>... | |
{ | |
template<typename T> | |
auto & prev() | |
{ | |
return static_cast<list_mixin<CRTP, T> &>(*this).prev; | |
} | |
template<typename T> | |
auto & prev() const | |
{ | |
return static_cast<const list_mixin<CRTP, T> &>(*this).prev; | |
} | |
template<typename T> | |
auto & next() | |
{ | |
return static_cast<list_mixin<CRTP, T> &>(*this).next; | |
} | |
template<typename T> | |
auto & next() const | |
{ | |
return static_cast<const list_mixin<CRTP, T> &>(*this).next; | |
} | |
}; | |
class thread : public list_mixins<thread, class all, class same_state> | |
{ | |
}; | |
#include <iostream> | |
int main() | |
{ | |
std::cout << thread{}.prev<class all>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment