Skip to content

Instantly share code, notes, and snippets.

@Daiver
Created December 6, 2015 18:24
Show Gist options
  • Save Daiver/55a7062a8f81d6eb022b to your computer and use it in GitHub Desktop.
Save Daiver/55a7062a8f81d6eb022b to your computer and use it in GitHub Desktop.
#include <boost/fusion/tuple.hpp>
#include <boost/fusion/view.hpp>
#include <boost/fusion/algorithm.hpp>
#include <boost/fusion/adapted/struct/adapt_struct.hpp>
#include <boost/type_traits.hpp>
#include <boost/mpl/arg.hpp>
#include <boost/lambda/lambda.hpp>
#include <string>
#include <iostream>
using namespace boost::lambda;
using namespace boost::fusion;
using namespace std;
class Student {
public:
std::string name;
int age;
double averageMark;
long weight;
};
BOOST_FUSION_ADAPT_STRUCT(
Student,
(std::string, name)
(int, age)
(double, averageMark)
(long, weight)
);
int main()
{
Student s{"Vasya", 34, 2.3, 40};
filter_view<Student, boost::is_integral<boost::mpl::arg<1>>> v{s};
for_each(v, cout << _1 << '\n');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment