On 29/07/15 21:55 -0700, Tim Shen wrote:
- typedef _Matcher<typename _TraitsT::char_type> _MatcherT; + typedef _Matcher<_Char_type> _MatcherT; + static_assert(sizeof(_MatcherT) == sizeof(_Matcher<char>), + "The aussmption std::function<bool(char)> has " + "the same size as std::function<bool(T)> is violated"); + static_assert(alignof(_MatcherT) == alignof(_Matcher<char>), + "The aussmption std::function<bool(char)> has " + "the same alignment as std::function<bool(T)> is violated");
Good idea adding these assertions, but "aussmption" :-) In accordance with https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41759 we should avoid negative wording ("X is not Y" or "X does not meet Y") in static assertions, so maybe something like: static_assert(alignof(_MatcherT) == alignof(_Matcher<char>), "std::function<bool(T)> has the same size as " "std::function<bool(char)>"); or: static_assert(alignof(_MatcherT) == alignof(_Matcher<char>), "std::function<bool(T)> must have the same size as " "std::function<bool(char)>");
- _MatcherT _M_matches; // for _S_opcode_match + _MatcherT& + _M_get_matcher() + { return *reinterpret_cast<_MatcherT*>(this->_M_matcher_storage._M_addr()); } - explicit _State(_Opcode __opcode) : _State_base(__opcode) { } + const _MatcherT& + _M_get_matcher() const + { return *reinterpret_cast<const _MatcherT*>(this->_M_matcher_storage._M_addr()); }
These can use static_cast, because _M_addr() returns void* OK for trunk with those two tweaks, thanks!