Skip to content

Instantly share code, notes, and snippets.

@mach-kernel
Created July 29, 2015 19:55
Show Gist options
  • Save mach-kernel/b922b4a1b268c5d47af4 to your computer and use it in GitHub Desktop.
Save mach-kernel/b922b4a1b268c5d47af4 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <vector>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/include/size.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
struct MyStruct
{
int x;
int y;
};
BOOST_FUSION_ADAPT_STRUCT(
MyStruct,
(int, x)
(int, y)
);
int main()
{
#ifndef PRINT
#define PRINT(unused, number, data) \
std::cout << number << std::endl;
#endif
MyStruct s;
std::cout << boost::fusion::size(s) << std::endl;
//line below works - it iterate and write output
BOOST_PP_REPEAT(2, PRINT, "here I will pass my data")
//this won't compile
BOOST_PP_REPEAT(boost::fusion::size(s), PRINT, "here i will pass my data")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment