C
Christopher
I don't understand why I am getting errors on this code. My goal is to
access a map by index and I find no appropriate method, so I tried
this:
const D3DXMATRIX & Material::GetMatrix(const unsigned index,
std::string & name)
{
if( index < 0 || index > m_matrices.size() - 1 )
{
throw BaseException("Invalid index requested",
"const D3DXMATRIX & GetMatrix(const unsigned
index, std::string & name)",
"Material.cpp");
}
Matrices::const_iterator it = m_matrices.begin();
it = it + index; // Error here!
it->second;
// snip
}
where I have the following typedefs in the header
template <class T>
struct Attribute
{
bool m_initialized;
T m_value;
};
/**
* Map of matrix attributes
*
* key - matrix variable name as it appears in the DirectX effect
* value - Attribute structure containing the matrix
*/
typedef std::map<std::string, Attribute<D3DXMATRIX> > Matrices;
Matrices m_matrices;
Anyone know how to achieve my goal?
I want to pretty much allow another specific class access to the
entire map, I just don't want to expose the details,
so I attempted this access by index along with a get size combination,
which isn't working.
access a map by index and I find no appropriate method, so I tried
this:
const D3DXMATRIX & Material::GetMatrix(const unsigned index,
std::string & name)
{
if( index < 0 || index > m_matrices.size() - 1 )
{
throw BaseException("Invalid index requested",
"const D3DXMATRIX & GetMatrix(const unsigned
index, std::string & name)",
"Material.cpp");
}
Matrices::const_iterator it = m_matrices.begin();
it = it + index; // Error here!
it->second;
// snip
}
where I have the following typedefs in the header
template <class T>
struct Attribute
{
bool m_initialized;
T m_value;
};
/**
* Map of matrix attributes
*
* key - matrix variable name as it appears in the DirectX effect
* value - Attribute structure containing the matrix
*/
typedef std::map<std::string, Attribute<D3DXMATRIX> > Matrices;
Matrices m_matrices;
Anyone know how to achieve my goal?
I want to pretty much allow another specific class access to the
entire map, I just don't want to expose the details,
so I attempted this access by index along with a get size combination,
which isn't working.