Created
December 6, 2020 13:03
-
-
Save xueliu/f64df6c279f0c4973676280b01429239 to your computer and use it in GitHub Desktop.
[c++ tuple] a simple tuple implementation #C++
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 ... Values> class tuple; | |
template<> class tuple<> {}; | |
template<typename Head, typename ... Tail> | |
class tuple<Head, Tail...> : private tuple<Tail...> | |
{ | |
private: | |
typedef tuple<Tail...> inherited; | |
public: | |
tuple() {} | |
tuple(Head v, Tail ... vtail) | |
: m_head(v) | |
, inherited(vtail ...) {} | |
typename Head::type head() { return m_head;} | |
inherited& tail() { return *this; } | |
protected: | |
Head m_head; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment