473,396 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with non-const first_type in std::map

Question: In the following template function signature

template <class MAP>
int matchAbbreviationMap(
const MAP & choices,
typename MAP::value_type::first_type & arg,
typename MAP::value_type::second_type & val)
{
...

MAP is a std::map or std::multi_map so MAP::value_type::first_type is a const
type. I want arg to have the same type but to be non-const. Is there some
way to do this generically without specifying a redundant type in the template
parameters?

Thanks,
--
Paul M. Dubuc
Apr 11 '06 #1
1 1742
Paul Dubuc wrote:
Question: In the following template function signature

template <class MAP>
int matchAbbreviationMap(
const MAP & choices,
typename MAP::value_type::first_type & arg,
typename MAP::value_type::second_type & val)
{
...

MAP is a std::map or std::multi_map so MAP::value_type::first_type is
a const type. I want arg to have the same type but to be non-const. Is
there some way to do this generically without specifying a
redundant type in the template parameters?


You could try this:

// auxiliary templates for type extraction
template<class T> struct drop_const { typedef T type; };
template<class T> struct drop_const<T const &> { typedef T type; }

..
template<class MAP>
int match...
typename drop_const<MAP::value_type::first>::type & arg,
...

Or some such.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Apr 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Noixe | last post by:
Hello, I'm italian then sorry for my bad english: In this source #include <iostream> #include <map> #include <string>
8
by: heather.memmel | last post by:
I am in no way a scripter/programmer of any kind but I am in charge of a number of online videos. Anyway I need help debugging my javascript which has been pieced together from several other...
2
by: Amanda | last post by:
From a guy in Microsoft newsgroups: | In *comp.databases.ibm-db2* there are always IBM guys | from the Toronto labs on line.Post with the | -for the love of god please help- | line...
30
by: Raymond Hettinger | last post by:
Proposal -------- I am gathering data to evaluate a request for an alternate version of itertools.izip() with a None fill-in feature like that for the built-in map() function: >>> map(None,...
3
by: Dean Craig | last post by:
I'm working with the new ASP.NET AJAX Control Toolkit. I have a map that has several key areas (hot spots) where when the user hovers over them, I want to pop up a small window with information in...
11
by: Dennis Jones | last post by:
Hello, I would like to know if there is a known pattern for creating a map of reference-counted objects, such that when the last reference to an object is deleted, the element referring to that...
1
by: nnightwolf | last post by:
hey guys, i'm just a noob in vb.net but i have to make a program which goes like this: i have a database with text(names) and links to images(locations).--> Column1 Column2 name1 image1 name2...
10
by: hyozan.ux3 | last post by:
I want to create a program that I type in a word. for example... chaos each letter equals a number.... A=1 B=20
2
by: yeshello54 | last post by:
so here is my problem...in a contact manager i am trying to complete i have ran into an error..we have lots of code because we have some from class which we can use...anyways i keep getting an error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.