Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, April 2008
is there a way to initialise a static const QHash datamember?


Message 1 in thread

??

Message 2 in thread

only by constructing it from a non-const other QHash? 
(write a function that creates this one for you)
http://doc.trolltech.com/4.3/qhash.html#QHash-2

Cheers,
Peter
> -----Ursprüngliche Nachricht-----
> Von: Naja Melan [mailto:najamelan@xxxxxxxxx] 
> Gesendet: Montag, 21. April 2008 17:52
> An: qt-interest@xxxxxxxxxxxxx
> Betreff: is there a way to initialise a static const QHash datamember?
> 
> ??
> 
> 

--
 [ signature omitted ] 

Message 3 in thread

Naja Melan wrote:
> ??
.h file

struct CFoo
{   
    static const QHash<int, int> m_hash;
};



.cpp file

QHash<int, int> a_way_to_initialise a_static_const_QHash_datamember()
{
   QHash<int, int> myHash;

  // insert the data
 
  return myHash;
}

const QHash<int, int> CFoo::_hash = a_way_to_initialise 
a_static_const_QHash_datamember();

--
 [ signature omitted ] 

Message 4 in thread

ok,

so i can't do it compile time? right now, i just fill in the data in a non
const one the first time the constructor is ran...

minus being its not const, but plus being i don't need extra files...

thx for the ideas though, i will consider what's least evil...

naja

ps: sorry Vladimir for receiving it twice, but recently gmail doesn't seem
to be replying to the list anymore when just clicking reply;..

Message 5 in thread

Naja Melan wrote:
>ok,
>
>so i can't do it compile time?

No. That's not allowed in C++ right now.

With C++0x, there will be a construct to allow you to do it. We'll 
probably add support to it soon after the standard is out, but you'll 
have to be very careful about using it with old (i.e., all of today's) 
compilers.

-- 
 [ signature omitted ] 

Attachment: signature.asc
Description: This is a digitally signed message part.