且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

对std :: regex_match(和std :: regex_search)的参数的生命周期的约束

更新时间:2023-02-19 23:40:51

在采用 tr1 :: regex std :: regex 期间对此可能性的任何讨论,所以我认为没有考虑。事后看来,这当然是我们应该预见的一个陷阱。在我的头顶部,一个重载,需要一个 std :: string&&& 会指示涉及一个临时,需要一个副本。所以我要向标准委员会报告。 (完全公开:我写了Dinkumware实现,这是微软的船)

I don't recall any discussion of this possibility during the adoption of tr1::regex or std::regex, so I think it simply was not considered. In hindsight, it's certainly a trap that we should have foreseen. Off the top of my head, an overload that takes a std::string&& would signal that a temporary is involved, and a copy is needed. So I'd report it to the Standards Committee. (full disclosure: I wrote the Dinkumware implementation, which is what Microsoft ships)