Boost logo

Boost Users :

Subject: Re: [Boost-users] re alization of Last Recently Used cache with boost::multi_index
From: Joaquin M Lopez Munoz (joaquin_at_[hidden])
Date: 2009-03-04 16:29:53


Hi Pavel,

pavel5 wrote:
>
> I am trying to realize class for strings caching using boost::multi_index.
> [...]
> My class works without any problem, but i want to have template class, for
> easily type of key and value selection. I modified my source:
> [...]
> After modification, gcc compiler prints for line:
>
> LRUCacheItems::nth_index<0>::type& hash_index=cache.get<0>();
>
> many errors:[...]
>

Replace the offending line with

typename LRUCacheItems::nth_index<0>::type& hash_index=cache.template
get<0>();

Note the extra "typename" and also the "template" keyword between
"cache." and "get<0>()". After templatizing your LRUCache, the expression
happens to be in a so-called dependent context, and turns out you've got to
help
the compiler figure it out right (i.e. disambiguate from some other
interpretations
theoretically possible in the given context). Learn more about this issue at

http://www.informit.com/guides/content.aspx?g=cplusplus&seqNum=388

Hope this helps,

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo

-- 
View this message in context: http://www.nabble.com/realization-of-Last-Recently-Used-cache-with-boost%3A%3Amulti_index-tp22326432p22339783.html
Sent from the Boost - Users mailing list archive at Nabble.com.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net