Skip to content

Commit a8949ec

Browse files
committed
update: 完成 26 题
Signed-off-by: YdrMaster <[email protected]>
1 parent c248b13 commit a8949ec

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

exercises/26_std_string/main.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#include "../exercise.h"
22
#include <string>
33

4+
// READ: 字符串 <https://zh.cppreference.com/w/cpp/string/basic_string>
5+
46
int main(int argc, char **argv) {
5-
ASSERT(false, "todo!");
7+
// READ: 字符串字面量 <https://zh.cppreference.com/w/cpp/string/basic_string/operator%22%22s>
8+
using namespace std::string_literals;
9+
auto hello = "Hello"s;
10+
auto world = "world";
11+
// READ: `decltype` 表达式 <https://zh.cppreference.com/w/cpp/language/decltype>
12+
// READ: `std::is_same_v` 元编程判别 <https://zh.cppreference.com/w/cpp/types/is_same>
13+
ASSERT((std::is_same_v<decltype(hello), ?>), "Fill in the missing type.");
14+
ASSERT((std::is_same_v<decltype(world), ?>), "Fill in the missing type.");
15+
// TODO: 将 `?` 替换为正确的字符串
16+
ASSERT(hello + ", " + world + '!' == "?", "Fill in the missing string.");
617
return 0;
718
}

0 commit comments

Comments
 (0)