The Wayback Machine - https://web.archive.org/web/20201129040959/https://github.com/changkun/modern-cpp-tutorial/pull/147
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime: fix std::make_unique header file #147

Open
wants to merge 1 commit into
base: master
from

Conversation

@inuoya
Copy link

@inuoya inuoya commented Nov 27, 2020

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

  • Fix typo error of XXX
  • Add description regarding XXX feature
  • Resolve error content of XXX

Reference

Please add reference if necessary


说明

此处详细说明 PR 的动机是什么、解决了什么样的问题。

变化箱单

  • 修复了 XXX 的 typo 错误
  • 增加了 XXX 相关的说明
  • 解决了关于 XXX 的描述性错误

参考文献

如果有请注明

Signed-off-by: Yang, Nuoya <nuoya.yang@aliyun.com>
@@ -90,7 +90,7 @@ C++14 给与了我们方便,允许捕获的成员用任意的表达式进行

```cpp
#include <iostream>
#include <utility>
#include <memory>

This comment has been minimized.

@changkun

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

This comment has been minimized.

@inuoya

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$

This comment has been minimized.

@changkun

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.