4

私は私に問題を与えている2つのことをしようとしています:

1)typedef std::vector
a 2)宣言std::auto_ptr

これらの両方が私にエラーを与えています"invalid use of template-name 'std::vector/auto_ptr' without an argument list"。エラーが発生しているヘッダーは次のとおりです。

ResourceLocationDefinition.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

EngineManager.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_ */
4

2 に答える 2

6

テンプレートを使用する場合は、ベクターのテンプレートパラメータを指定する必要があります。おそらく、次のようなことをしたいと思うでしょう。

typedef std::vector<ResourceLocationDefinition> ResourceLocationDefinitionVector;

ResourceLocationDefinitionベクターがオブジェクトインスタンスを参照していることを意味します。

そしてあなたのauto_ptrようなもののために:

std::auto_ptr<Root> root;

Ogre::Rootそこにポインタが欲しいと思いますよね?

于 2012-11-23T22:30:12.257 に答える
0

エラーはかなり明らかです。auto_ptrvectorはテンプレートです。実際に使用するタイプを指定する必要があります。

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(ブースト依存関係がある場合)の使用を検討してください。

于 2012-11-23T22:30:04.283 に答える