• <legend id='G5jNN'><style id='G5jNN'><dir id='G5jNN'><q id='G5jNN'></q></dir></style></legend>

    <small id='G5jNN'></small><noframes id='G5jNN'>

  • <i id='G5jNN'><tr id='G5jNN'><dt id='G5jNN'><q id='G5jNN'><span id='G5jNN'><b id='G5jNN'><form id='G5jNN'><ins id='G5jNN'></ins><ul id='G5jNN'></ul><sub id='G5jNN'></sub></form><legend id='G5jNN'></legend><bdo id='G5jNN'><pre id='G5jNN'><center id='G5jNN'></center></pre></bdo></b><th id='G5jNN'></th></span></q></dt></tr></i><div id='G5jNN'><tfoot id='G5jNN'></tfoot><dl id='G5jNN'><fieldset id='G5jNN'></fieldset></dl></div>
      <tfoot id='G5jNN'></tfoot>
          <bdo id='G5jNN'></bdo><ul id='G5jNN'></ul>

        error::make_unique 不是‘std’的成员

        时间:2023-10-18
        <i id='rbkOL'><tr id='rbkOL'><dt id='rbkOL'><q id='rbkOL'><span id='rbkOL'><b id='rbkOL'><form id='rbkOL'><ins id='rbkOL'></ins><ul id='rbkOL'></ul><sub id='rbkOL'></sub></form><legend id='rbkOL'></legend><bdo id='rbkOL'><pre id='rbkOL'><center id='rbkOL'></center></pre></bdo></b><th id='rbkOL'></th></span></q></dt></tr></i><div id='rbkOL'><tfoot id='rbkOL'></tfoot><dl id='rbkOL'><fieldset id='rbkOL'></fieldset></dl></div>

        <small id='rbkOL'></small><noframes id='rbkOL'>

            <tbody id='rbkOL'></tbody>

            <bdo id='rbkOL'></bdo><ul id='rbkOL'></ul>
              • <tfoot id='rbkOL'></tfoot>
                • <legend id='rbkOL'><style id='rbkOL'><dir id='rbkOL'><q id='rbkOL'></q></dir></style></legend>

                  本文介绍了error::make_unique 不是‘std’的成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试编译发布在代码审查上的以下线程池程序以对其进行测试.

                  I am trying to compile the following thread pool program posted on code review to test it.

                  https://codereview.stackexchange.com/questions/55100/platform-independant-thread-pool-v4

                  但我收到错误

                  threadpool.hpp: In member function ‘std::future<decltype (task((forward<Args>)(args)...))> threadpool::enqueue_task(Func&&, Args&& ...)’:
                  threadpool.hpp:94:28: error: ‘make_unique’ was not declared in this scope
                       auto package_ptr = make_unique<task_package_impl<R, decltype(bound_task)>>  (std::move(bound_task), std::move(promise));
                                          ^
                  threadpool.hpp:94:81: error: expected primary-expression before ‘>’ token
                       auto package_ptr = make_unique<task_package_impl<R, decltype(bound_task)>>(std::move(bound_task), std::move(promise));
                                                                                               ^
                  main.cpp: In function ‘int main()’:
                  main.cpp:9:17: error: ‘make_unique’ is not a member of ‘std’
                   auto ptr1 = std::make_unique<unsigned>();
                               ^
                  main.cpp:9:34: error: expected primary-expression before ‘unsigned’
                   auto ptr1 = std::make_unique<unsigned>();
                                                ^
                  main.cpp:14:17: error: ‘make_unique’ is not a member of ‘std’
                   auto ptr2 = std::make_unique<unsigned>();
                               ^
                  main.cpp:14:34: error: expected primary-expression before ‘unsigned’
                   auto ptr2 = std::make_unique<unsigned>();
                  

                  推荐答案

                  make_unique 是一个 即将推出的 C++14 功能,因此可能无法在您的编译器上使用,即使它符合 C++11.

                  make_unique is an upcoming C++14 feature and thus might not be available on your compiler, even if it is C++11 compliant.

                  然而,您可以轻松推出自己的实现:

                  You can however easily roll your own implementation:

                  template<typename T, typename... Args>
                  std::unique_ptr<T> make_unique(Args&&... args) {
                      return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
                  }
                  

                  (仅供参考,这里是最终版本make_unique 被投到 C++14 中.这包括覆盖数组的附加功能,但总体思路仍然相同.)

                  (FYI, here is the final version of make_unique that was voted into C++14. This includes additional functions to cover arrays, but the general idea is still the same.)

                  这篇关于error::make_unique 不是‘std’的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么语句不能出现在命名空间范围内? 下一篇:cc1plus:错误:无法识别的命令行选项“-std=c++11"用 g++

                  相关文章

                    <i id='FSFTm'><tr id='FSFTm'><dt id='FSFTm'><q id='FSFTm'><span id='FSFTm'><b id='FSFTm'><form id='FSFTm'><ins id='FSFTm'></ins><ul id='FSFTm'></ul><sub id='FSFTm'></sub></form><legend id='FSFTm'></legend><bdo id='FSFTm'><pre id='FSFTm'><center id='FSFTm'></center></pre></bdo></b><th id='FSFTm'></th></span></q></dt></tr></i><div id='FSFTm'><tfoot id='FSFTm'></tfoot><dl id='FSFTm'><fieldset id='FSFTm'></fieldset></dl></div>
                    • <bdo id='FSFTm'></bdo><ul id='FSFTm'></ul>

                    <tfoot id='FSFTm'></tfoot>

                  1. <legend id='FSFTm'><style id='FSFTm'><dir id='FSFTm'><q id='FSFTm'></q></dir></style></legend>

                      <small id='FSFTm'></small><noframes id='FSFTm'>