是否可以(对A类进行任何修改)进行以下工作?即,使最令人烦恼的解析出错?
class A {
};
int main() {
A a(); // can this be forced to be an error??
A b; // this should work
}
Run Code Online (Sandbox Code Playgroud) 我看到一个错误,我没有看到解决方案.一,相关代码:
namespace C {
struct RangeEntry {
size_t byte;
boost::optional<size_t> bit;
};
struct Range {
RangeEntry firstPart;
boost::optional<RangeEntry> secondPart;
boost::optional<size_t> shift;
};
}
BOOST_FUSION_ADAPT_STRUCT(
C::RangeEntry,
(size_t, byte)
(boost::optional<size_t>, bit)
)
BOOST_FUSION_ADAPT_STRUCT(
C::Range,
(C::RangeEntry , firstPart)
(boost::optional<C::RangeEntry> , secondPart)
(boost::optional<size_t> , shift)
)
... Declare the rules ...
karma::rule<Iterator, C::Range()> range;
karma::rule<Iterator, C::RangeEntry()> range_part;
... Define rules ...
range_part %= no_delimit[ulong_ << -(lit(":") << ulong_)];
range %= no_delimit[range_part << -(lit("-") << range_part)] << -(lit("<<") << ulong_);
Run Code Online (Sandbox Code Playgroud)
在该range %=部分,我得到编译错误
/usr/include/boost/spirit/home/karma/numeric/detail/numeric_utils.hpp:504:30: …Run Code Online (Sandbox Code Playgroud)