小编Igo*_*kov的帖子

使用 const std::string& 和 const std::vector<std::string>& 进行函数调用

我有带有签名的函数:

    void add_word_rule(const std::string& word);
    void add_multiple_word_rules(const std::vector<std::string>& words);
Run Code Online (Sandbox Code Playgroud)

问题是这样的。如果用户调用该函数

    add_word_rule({"word_1","word_2"});
Run Code Online (Sandbox Code Playgroud)

它将编译。如何确保这样的调用不会编译?我怎样才能禁用这个构造函数basic_string( InputIt first, InputIt last)?

c++

5
推荐指数
2
解决办法
156
查看次数

标签 统计

c++ ×1