I am trying to apply the BOOST_FUSION_ADAPT_ADT to class as shown below:
class XY {
private:
std::string x; // lhs
std::list<std::list<std::string>> y;
public:
std::list<std::list<std::string>> const &getY() const {
return y;
}
void setY(std::list<std::list<std::string>> const &y) {
this->y = y;
}
std::string const &getX() const { return x; }
void setX(std::string const &x) { this->x = x; }
};
However, I am getting the following error, I can't quite figure out what is wrong.
xxxxxxxxxxxxxxx: error: no matching function for call to ‘Rule::setY(const std::__cxx11::basic_string<char>&)’
(std::list<std::list<std::string>> const&, std::list<std::list<std::string>> const&, obj.getY(), obj.setY(val))
^
xxxxxxxxxxxxxxx: note: candidate: void Rule::setY(const std::__cxx11::list<std::__cxx11::list<std::__cxx11::basic_string<char> > >&)
void setY(std::list<std::list<std::string>> const &y) {
You don't sow how you used it. However, when I try it there is no problem:
#include <boost/fusion/adapted.hpp>
#include <boost/fusion/include/copy.hpp>
#include <string>
#include <list>
#include <fmt/ranges.h>
using namespace std::string_literals;
using Lists = std::list<std::list<std::string> >;
class XY {
private:
std::string x;
Lists y;
public:
void setY(Lists const& y) { this->y = y; }
void setX(std::string const& x) { this->x = x; }
[[nodiscard]] Lists const& getY() const { return y; }
[[nodiscard]] std::string const& getX() const { return x; }
};
BOOST_FUSION_ADAPT_ADT(XY,
(obj.getX(), obj.setX(val))
(obj.getY(), obj.setY(val))
)
int main() {
XY test;
boost::fusion::copy(
std::make_tuple("hello", Lists { {"world"s, "bye"s}, {"world"s} }),
test);
fmt::print("{}\n{}\n",
test.getX(),
test.getY());
}
Prints
hello
{{"world", "bye"}, {"world"}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.