Skip to content

Instantly share code, notes, and snippets.

@xueliu
Created December 6, 2020 13:03
Show Gist options
  • Save xueliu/f64df6c279f0c4973676280b01429239 to your computer and use it in GitHub Desktop.
Save xueliu/f64df6c279f0c4973676280b01429239 to your computer and use it in GitHub Desktop.
[c++ tuple] a simple tuple implementation #C++
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