Hey,
I've recently tried to use an existing C++ library.. Now i was trying to test test the library but i´m struggling with "string subscript out of range". I've just created a console project to test the output. The output that is "coming out" the function is of a template class. In this scenario it is a std::string(atleast what i think). When running the main with the calls to the dll, everything but this variables works.
When i ignore the assertion error in debug mode, i can see that the variable has the correct values eventually i printed it to console and it was okay.
Anyone has experience whit this situation. Below i have a example of the class:
template <class BODY>
class TPGPointer
{
public:
typedef BODY BodyType; // The type of the body.
protected:
BodyType* m_pBody;
TPGPointer(void) : m_pBody(NULL) {;}
// Constructs a handle instance with a pointer value of NULL. Throws no
// exceptions.
TPGPointer(BODY* pBody) : m_pBody(pBody) {;}
// Constructs a handle instance that points to the specified body. Throws no
// exceptions.
TPGPointer(const TPGPointer<BODY>& _second) : m_pBody(_second.m_pBody) {;}
// Constructs a handle instance that points to the same body as the second.
// Throws no exceptions.
TPGPointer<BODY>& operator=(BODY* ptr) {
// Assigns a new pointer value to the handle. The parameter is BODY*. Throws no
// exceptions.
this->m_pBody = ptr;
return *this;
}
public:
~TPGPointer(void) {;}
// Destructor. Throws no exceptions.
// Public Member Operators
....
// Public Member Functions
bool is_valid(void) const {
// Returns true if pointer is non-nil (NULL); otherwise returns false. Throws
// no exceptions.
return (this->m_pBody != NULL);
}
void swap_with(TPGPointer<BODY>& _second) {
// Swap bodies, if any, with another handle. Throws no exceptions.
BodyType* tmpptr = this->m_pBody;
this->m_pBody = _second.m_pBody;
_second.m_pBody = tmpptr;
}
void validate(void) const {
// Check if the pointer is valid, throwing an TPGException exception
// if the pointer is NULL. Throws an TPGException exception.
if (!this->is_valid()) throw CTPGException("Invalid pointer");
}
protected:
// Protected Member Function
BODY* get(void) const {
// Retrieves the handle's pointer value without validating it. Throws no
// exceptions.
return this->m_pBody;
}
};
I hope this is enough information....If not i've added my VS solution
Thanks