Skip to content

Instantly share code, notes, and snippets.

@mach-kernel
Created July 29, 2015 19:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mach-kernel/342d15e410171e0bc01e to your computer and use it in GitHub Desktop.
Save mach-kernel/342d15e410171e0bc01e 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