Re: Possible to declare move constructor of basic_symbol as noexcept?
Akim Demaille <[email protected]> Thu, 7 Jan 2021 06:30:14 +0100
| Newsgroups | gmane.comp.parsers.bison.general |
|---|---|
| Message-ID | <[email protected]> |
Hi Adrian, > Le 6 janv. 2021 à 20:43, Adrian <[email protected]> a écrit : > > Hello, > > Is there any possibility we can declare the move constructor of > basic_symbol as noexcept (if the semantic_types are noexcept > moveable)? > > I have a semantic value that is non-copyable (moveable only) and I > want an std::vector<symbol_type>. std::vector only calls the move > constructor when resizing if the move constructor is declared noexcept > > It seems to me that the issue might be that you would require all of > the semantic types to be noexcept moveable. You would need a > (potentially huge) noexcept predicate, but since it's generated code > maybe it's ok My C++ is rusting. What exactly are you asking for? From > #if 201103L <= YY_CPLUSPLUS > /// Move constructor. > basic_symbol (basic_symbol&& that) > : Base (std::move (that)) > , value () > { > switch (this->kind ()) > { > case symbol_kind::S_NUMBER: // NUMBER > value.move< int > (std::move (that.value)); > break; > > case symbol_kind::S_TEXT: // TEXT > case symbol_kind::S_item: // item > value.move< std::string > (std::move (that.value)); > break; > > case symbol_kind::S_list: // list > value.move< std::vector<std::string> > (std::move (that.value)); > break; > > default: > break; > } > > } > #endif to go to > #if 201103L <= YY_CPLUSPLUS > /// Move constructor. > basic_symbol (basic_symbol&& that) > noexcept ( > std::is_nothrow_move_constructible< int >::value > && std::is_nothrow_move_constructible< std::string >::value > && std::is_nothrow_move_constructible< std::vector<std::string> >::value > > ) > : Base (std::move (that)) > , value () right?