Skip to content

Commit

Permalink
stage
Browse files Browse the repository at this point in the history
  • Loading branch information
archibate committed Feb 28, 2023
1 parent 913374c commit 013f8d8
Show file tree
Hide file tree
Showing 23 changed files with 1,497 additions and 303 deletions.
11 changes: 0 additions & 11 deletions 1001/stl_map/experiment/main.cpp

This file was deleted.

290 changes: 0 additions & 290 deletions 1001/stl_map/slides.md

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

# 课程大纲

课程分为前半段和后半段,前半段主要介绍现代 C++,后半段主要介绍并行编程与优化。
第一季课程分为前半段和后半段,前半段主要介绍现代 C++,后半段主要介绍并行编程与优化。

1. 课程安排与开发环境搭建:cmake与git入门
1. 现代C++入门:常用STL容器,RAII内存管理
Expand All @@ -40,6 +40,8 @@
1. C++在ZENO中的工程实践:从primitive说起
1. 结业典礼:总结所学知识与优秀作业点评

第二季正在绝赞连载中...

# 前置条件

硬件要求:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
58 changes: 58 additions & 0 deletions stlseries/stl_map/experiment/cppdemangle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#pragma once

#include <typeinfo>
#include <type_traits>
#include <string>
#if (defined(__GNUC__) || defined(__clang__)) && __has_include(<cxxabi.h>)
#include <cxxabi.h>
#include <cstdlib>
#endif

namespace _cppdemangle_details {

static std::string cppdemangle(const char *name) {
#if (defined(__GNUC__) || defined(__clang__)) && __has_include(<cxxabi.h>)
int status;
char *p = abi::__cxa_demangle(name, 0, 0, &status);
std::string s = p ? p : name;
std::free(p);
#else
std::string s = name;
#endif
return s;
}

static std::string cppdemangle(std::type_info const &type) {
return cppdemangle(type.name());
}

template <class T>
static std::string cppdemangle() {
std::string s{cppdemangle(typeid(std::remove_cv_t<std::remove_reference_t<T>>))};
if (std::is_const_v<std::remove_reference_t<T>>)
s += " const";
if (std::is_volatile_v<std::remove_reference_t<T>>)
s += " volatile";
if (std::is_lvalue_reference_v<T>)
s += " &";
if (std::is_rvalue_reference_v<T>)
s += " &&";
return s;
}

}

using _cppdemangle_details::cppdemangle;

// Usage:
//
// cppdemangle<int>()
// => "int"
//
// int i;
// cppdemangle<decltype(i)>()
// => "int"
//
// int i;
// cppdemangle<decltype(std::as_const(i))>()
// => "int const &"
17 changes: 17 additions & 0 deletions stlseries/stl_map/experiment/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <bits/stdc++.h>
#include "print.h"
#include "cppdemangle.h"
#include "map_get.h"
using namespace std;

int main() {
map<string, int> m = {
{"answer", 42},
{"timeout", 4096},
};
m.insert({
{"timeout", 985},
{"delay", 211},
});
print(m);
}
Loading

0 comments on commit 013f8d8

Please sign in to comment.