1

In the Boost.Fusion documentation it says that BOOST_FUSION_ADAPT_STRUCT makes a struct a fully compatible Boost.Fusion random access sequence.
I tried the following:

#include <iostream>
#include <boost/fusion/include/adapt_struct.hpp>
#include <boost/fusion/include/at.hpp>

struct Str {
    int i;
    float j;
};

BOOST_FUSION_ADAPT_STRUCT(
    Str,
    (int, i)
    (float, j)
)

int main() {
    Str s;
    boost::fusion::at<0>(s) = 1;
}

And I received an error from the compiler saying "no matching function for call to at(Str&)".
The compiler I'm using is g++.
What am I doing wrong?
Thanks in advance.

Luc Touraille
  • 79,925
  • 15
  • 92
  • 137
Tal Zion
  • 1,331
  • 2
  • 14
  • 23

1 Answers1

4
boost::fusion::at<boost::mpl::int_<0>>(s) = 1;

Because N must be an MPL integral constant

Boost::fusion::at

awesoon
  • 32,469
  • 11
  • 74
  • 99