Skip to content

Instantly share code, notes, and snippets.



Last active Mar 22, 2019
What would you like to do?
#include <iostream>
#include <brigand/brigand.hpp>
template<typename Members>
class TaggedTuple{
template<typename TagType>
struct createMember{
using type = typename TagType::type;
using DataTuple = brigand::transform<Members, createMember<brigand::_1>>;
brigand::as_tuple<DataTuple> members;
template<typename TagType>
auto& get(){
using index = brigand::index_of<Members, TagType>;
return std::get<index::value>(members);
int main(){
struct FloatTag{
using type = float;
struct IntTag{
using type = int;
struct DoubleTag{
using type = float;
TaggedTuple<brigand::list<FloatTag, IntTag, DoubleTag>> tagged;
tagged.get<DoubleTag>() = 200;
auto val = tagged.get<DoubleTag>();
std::cout << val << std::endl;
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment