2cl (pronounce "toccle") is a functional programming extension for C++
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
430 B

#pragma once
#include <stddef.h>
namespace cl
{
template<typename a, typename ...b>
class tuple{
a _mine;
tuple<b...> _child;
template<size_t idx, a, b...>
friend a get();
public:
tuple(a mine, b ...child)
: _mine(mine)
, _child(child...)
{}
};
template<size_t idx, typename ...a>
constexpr auto get(tuple<a...> v)
{
if constexpr (idx!=0)
return get<idx-1>(v._child);
else
return v._mine;
}
}