royqh1979 / RedPanda-CPP

A light-weight C/C++ IDE based on Qt
GNU General Public License v3.0
953 stars 103 forks source link

建议增强对 C++ 在括号内进行的字符串拼接表达式的智能补全提示支持 #312

Closed West-Pavilion closed 5 months ago

West-Pavilion commented 5 months ago

建议增强对 C++ 在括号内进行的字符串拼接表达式的智能补全提示支持

希望以下的代码中的函数调用 ".c_str()" 在未来的 小熊猫C++ 中能有智能补全提示支持

#include <iostream>

/* 建议增强对 C++ 在括号内进行的字符串拼接表达式的智能补全提示支持 */

/* 希望以下的测试代码中的 ".c_str()" 在未来的 小熊猫C++ 中能有智能补全提示支持 */

int main() {
    /* 在括号内进行的简单字符串拼接 */
    std::string base1{"This is a expression about "};
    std::string str{base1};
    std::cout << (str + "a string + char* in parentheses").c_str() << std::endl;
    auto str_char_add_equal_auto = (str += "a string += char* in parentheses"
                                           " returning to an auto variable");
    std::cout << str_char_add_equal_auto.c_str() << std::endl;
    str = base1;
    std::cout << (str += "a string += char* in parentheses").c_str() << std::endl;

    std::string base2{" is performed in this expression"};
    str = base2;
    std::cout << ("a char* + string in parentheses" + base2).c_str() << std::endl;

    /* 复杂表达式中的字符串拼接运算 */
    str = " a string";
    std::cout << ("multiple concatenating about" + str + " and" + " a char*").c_str() << std::endl;
    std::cout << ("complex expression1 about" + (" a char* +" + str)).c_str() << std::endl;
    std::cout << ("complex expression2 about" + (str += " += a char*")).c_str() << std::endl;
    auto multiple_concatenating_auto = ("multiple concatenating about" + str + " and" + " a char*");
    std::cout << multiple_concatenating_auto.c_str() << std::endl;
    auto complex_expression1_auto = ("complex expression1 about" + (" a char* +" + str));
    std::cout << complex_expression1_auto.c_str() << std::endl;
    auto complex_expression2_auto = ("complex expression2 about" + (str += " += a char*"));
    std::cout << complex_expression2_auto.c_str() << std::endl;
}

下面是对应的测试代码:

建议增强对 C++ 在括号内进行的字符串拼接表达式的智能补全提示支持.zip

royqh1979 commented 5 months ago

真有人这么写程序嘛。好像没多大用