Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
runtime: fix std::make_unique header file #147
Conversation
Signed-off-by: Yang, Nuoya <nuoya.yang@aliyun.com>
| @@ -90,7 +90,7 @@ C++14 给与了我们方便,允许捕获的成员用任意的表达式进行 | |||
|
|
|||
| ```cpp | |||
| #include <iostream> | |||
| #include <utility> | |||
| #include <memory> | |||
changkun
Nov 27, 2020
Owner
#include <memory> does not exist in the apple clang. Since we declared the compile environment:
> clang++ -v
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
It is better to not do this change. See https://changkun.de/modern-cpp/zh-cn/01-intro/index.html
inuoya
Nov 27, 2020
Author
modern-cpp-tutorial/book/zh-cn$ echo "
#include <iostream>
#include <utility>
int main() {
auto important = std::make_unique<int>(1);
auto add = [v1 = 1, v2 = std::move(important)](int x, int y) -> int {
return x + y + v1 + (*v2);
};
std::cout << add(3, 4) << std::endl;
return 0;
}" | clang++-10 -std=c++14 -x c++ - -o mytest
<stdin>:5:27: error: no member named 'make_unique' in namespace 'std'
auto important = std::make_unique<int>(1);
~~~~~^
<stdin>:5:42: error: expected '(' for function-style cast or type construction
auto important = std::make_unique<int>(1);
~~~^
<stdin>:7:31: error: use of undeclared identifier 'v2'
return x + y + v1 + (*v2);
^
3 errors generated.
modern-cpp-tutorial/book/zh-cn$ echo "
#include <iostream>
#include <memory>
int main() {
auto important = std::make_unique<int>(1);
auto add = [v1 = 1, v2 = std::move(important)](int x, int y) -> int {
return x + y + v1 + (*v2);
};
std::cout << add(3, 4) << std::endl;
return 0;
}" | clang++-10 -std=c++14 -x c++ - -o mytest
modern-cpp-tutorial/book/zh-cn$
changkun
Nov 27, 2020
Owner
Interesting, perhaps the issue was already fixed. Thanks for the clarification.
Could you please also fix the code in book/en-us/03-runtime.md and code in code/3?


Signed-off-by: Yang, Nuoya nuoya.yang@aliyun.com
resolve #issue_id
Description
Please describe the motivation of this pull request, and what problem was solved in this PR.
Change List
Reference
Please add reference if necessary
说明
此处详细说明 PR 的动机是什么、解决了什么样的问题。
变化箱单
参考文献
如果有请注明