Код: Выделить всё
#include
#include
auto main() -> int { std::shared_ptr ptr{}; }
< /code>
Но это не: < /p>
module;
#include
#include
export module main;
import std;
auto main() -> int { std::shared_ptr ptr{}; }
< /code>
Пример ошибки: < /p>
In file included from /workspaces/cpp_project/src/toy/tmp.cppm:3:
In file included from /usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/memory:82:
In file included from /usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr.h:53:
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr_base.h:1783:15: error: cannot befriend target of using declaration
1783 | friend _Del* get_deleter(const __shared_ptr&) noexcept;
| ^
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr.h:175:31: note: in instantiation of template class 'std::__shared_ptr' requested here
175 | class shared_ptr : public __shared_ptr
| ^
/workspaces/cpp_project/src/toy/tmp.cppm:10:68: note: in instantiation of template class 'std::shared_ptr' requested here
10 | auto main() -> int { [[maybe_unused]] std::shared_ptr ptr{}; }
| ^
/usr/lib/gcc/x86_64-redhat-linux/15/../../../../include/c++/15/bits/shared_ptr.h:79:5: note: target of using declaration
79 | get_deleter(const __shared_ptr& __p) noexcept
| ^
/usr/include/c++/15/bits/std.cc:1938:14: note: using declaration
1938 | using std::get_deleter;
| ^
< /code>
Есть ли способ обойти это? Для контекста я пишу модуль, который импортирует std Подробнее здесь: https://stackoverflow.com/questions/797 ... and-module