没有参数列表的模板名称使用无效
Invalid use of template name without argument list
我正在尝试做两件事,这给我带来了问题:
1) 键入定义std::vector
2) 申报std::auto_ptr
这两个都给了我错误"invalid use of template-name 'std::vector/auto_ptr' without an argument list"
.这是我导致错误的标头:
资源位置定义.h
// ResourceLocationDefinition contains the information needed
// by Ogre to load an external resource.
#ifndef RESOURCELOCATIONDEFINITION_H_
#define RESOURCELOCATIONDEFINITION_H_
#include "string"
#include "vector"
struct ResourceLocationDefinition
{
ResourceLocationDefinition(std::string type, std::string location, std::string section) :
type(type),
location(location),
section(section)
{
}
~ResourceLocationDefinition() {}
std::string type;
std::string location;
std::string section;
};
typedef std::vector ResourceLocationDefinitionVector;
#endif
引擎管理器.h
#ifndef ENGINEMANAGER_H_
#define ENGINEMANAGER_H_
#include "memory"
#include "string"
#include "map"
#include "OGRE/Ogre.h"
#include "OIS/OIS.h"
#include "ResourceLocationDefinition.h"
// define this to make life a little easier
#define ENGINEMANAGER OgreEngineManager::Instance()
// All OGRE objects are in the Ogre namespace.
using namespace Ogre;
// Manages the OGRE engine.
class OgreEngineManager :
public WindowEventListener,
public FrameListener
{
public:
// Bunch of unrelated stuff to the problem
protected:
// Constructor. Initialises variables.
OgreEngineManager();
// Load resources from config file.
void SetupResources();
// Display config dialog box to prompt for graphics options.
bool Configure();
// Setup input devices.
void SetupInputDevices();
// OGRE Root
std::auto_ptr root;
// Default OGRE Camera
Camera* genericCamera;
// OGRE RenderWIndow
RenderWindow* window;
// Flag indicating if the rendering loop is still running
bool engineManagerRunning;
// Resource locations
ResourceLocationDefinitionVector resourceLocationDefinitionVector;
// OIS Input devices
OIS::InputManager* mInputManager;
OIS::Mouse* mMouse;
OIS::Keyboard* mKeyboard;
};
#endif /* ENGINEMANAGER_H_ */
使用模板时,您必须提供模板参数,对于您的向量,您可能希望执行以下操作:
typedef std::vector<ResourceLocationDefinition> ResourceLocationDefinitionVector;
这意味着您的矢量引用ResourceLocationDefinition
对象实例。
对于您的auto_ptr
,请像这样:
std::auto_ptr<Root> root;
我相信你想要一个Ogre::Root
指针,对吧?
错误很明显。 auto_ptr
和vector
是模板。它们要求您指定实际要与它们一起使用的类型。
struct my_type {
int x, y;
};
std::vector<my_type> v; // a vector of my_type
std::vector<int> iv; // a vector of integers
关于auto_ptr
:由于其奇怪的语义,它已被弃用。考虑使用 std::unique_ptr
(在您的平台上可用时)或boost::scoped_ptr
(当您有提升依赖项时)。
相关文章:
- 为什么 CRTP 模板C++给出无效参数错误?
- 为什么此字符串在传递到stoi时被视为无效参数
- boost::asio::async_write无效参数
- C ++回测问题:如何检查构造函数在假定失败时是否失败(给定输入的无效参数)
- 无效参数 C++ cygwin
- 套接字接受无效参数 (c++)
- 从带有 getline() 的文件读入一行上有多个信息得到无效参数错误
- 将无效参数传递给将无效参数视为致命的函数
- 如何避免字符串到整数转换情况下的无效参数异常
- 张量流 无效参数:In[0] 不是矩阵
- cudaFreeHost() 无效参数错误
- 未经治疗的例外,无效的参数传递给了一个认为无效参数作用的函数
- C++带有可变参数模板的无效参数
- std::find是否隐式修复无效参数
- 为什么这个程序告诉我传递了无效参数
- 在Win32中获取SetConsolecursorPosition函数的ERRORRORNO 87(无效参数)
- MSVCR120.dll的无效参数错误(在64位窗口中构建Tesseract Lib)
- 在C++中使用字符串类的 .substr 获取无效参数
- MySQL++ 无效参数错误
- 搜索无效参数