c++ - 分配器:“没有可用的成员”。我该如何解决?
问题描述
因此,在呈现代码的下一行,我有 IntelliSense 警告:“没有可用的成员”。怎么了?在正常情况下,似乎有一些选项,如“分配”、“解除分配”等。
namespace MyLib
{
template <typename T,
template <typename Y> class Allocator = std::allocator>
class Vector
{
private:
std::size_t capacityV;
std::size_t sizeV;
T* arr;
public:
typedef Allocator<T> AllocatorType;
typedef Vector<T, Allocator> VectorType;
template<typename T>
using AllocTraits = std::allocator_traits<Allocator<T>>;
std::allocator_traits<Allocator<T>>:: //HERE!
其实std::allocator_traits<std::allocator<T>>::
也行不通。但在这些情况下有效(就像std::allocator_traits<Allocator<T>>::
):
template <
typename T,
template <typename Y> class Allocator = std::allocator> // use std::allocator as default allocator
std::unique_ptr<T, std::function<void(T*)>> move_with_allocator(
T&& stack_object, Allocator<T> allocator = Allocator<T>())
{
using AllocTraits = std::allocator_traits<Allocator<T>>;
std::allocator_traits<std::allocator<T>>::allocate(allocator, 1); //WORKING FINE HERE
视觉工作室 2019
解决方案
我怀疑你想要Template Intellisense。如果 Intellisense 对可能的模板参数有所了解,它可以提供更好的提示。
推荐阅读
- java - 我在以下 Java 代码中遇到错误。我应该在显示状态的 else if 语句下使用 if 语句吗?
- linux - 在linux终端中将文件复制到一堆子目录的最佳方法是什么
- node.js - firebase deploy 找不到与模式“'src/**/*'”匹配的文件
- r - R Shiny:生成与用户选择一样多的输出的循环
- java - 没有名为“transactionManager”的 bean 可用:
- powershell - VSCode 运行 PowerShell 脚本 VS 每个命令分别产生不同的结果
- css - 修复了在 Firefox 上工作的导航栏,但在 Chrome 上不工作
- cytoscape.js - Cytoscapejs:如何防止渲染的子图缩小视野?
- javascript - 如何在 chart.js 中填充数据
- c++ - 如何在主函数和线程之间传输数据?