user768417
user768417

Reputation:

Invalid use of template name without argument list

I'm attempting to do two things which are giving me problems:

1) typedef an std::vector
2) declare a std::auto_ptr

Both of these are giving me the error "invalid use of template-name 'std::vector/auto_ptr' without an argument list". Here's my headers where the error is being caused:

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_ */

Upvotes: 4

Views: 24928

Answers (2)

imreal
imreal

Reputation: 10358

When using templates, you have to provide template parameters, for your vector, you probably want to do something like this:

typedef std::vector<ResourceLocationDefinition> ResourceLocationDefinitionVector;

Meaning that your vector references ResourceLocationDefinition object instances.

and for your auto_ptr something like this:

std::auto_ptr<Root> root;

I believe you want an Ogre::Root pointer there right?

Upvotes: 6

pmr
pmr

Reputation: 59811

The error is pretty clear. auto_ptr and vector are templates. They require you to specify the type that you actually want to use with them.

struct my_type {
  int x, y;
}; 
std::vector<my_type> v; // a vector of my_type
std::vector<int> iv; // a vector of integers

Concerning auto_ptr: It has been deprecated because of its weird semantics. Consider using a std::unique_ptr (when available on your platform) or boost::scoped_ptr (when you have a boost dependency.)

Upvotes: 0

Related Questions