Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > std::map::iterator arithmetic problems

Reply
Thread Tools

std::map::iterator arithmetic problems

 
 
Christopher
Guest
Posts: n/a
 
      01-13-2009
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.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
BigDecimal and double arithmetic problems Ramon Java 12 11-03-2008 12:58 PM
Problems with Arithmetic Operators in a Perl hash coolchick Perl Misc 5 11-05-2007 01:01 PM
Usual Arithmetic Conversions-arithmetic expressions joshc C Programming 5 03-31-2005 02:23 AM
Arithmetic Libraries ALuPin VHDL 1 02-10-2004 04:37 PM
Synthesisable fixed-point arithmetic package Jonathan Bromley VHDL 1 08-15-2003 03:32 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57