Hi,
Having problem with boost and stuck.
I have the following:
std::map <std::string, boost::anybinaryHeader;
and somewere else I write:
---------------
binaryHeader.insert(make_pair("job", 0));
binaryHeader.insert(make_pair("line", 0));
binaryHeader.insert(make_pair("reel", 0));
binaryHeader.insert(make_pair("Ensemble", 0));
---------------
further down in another function the following does not work:
---------------
for( map<std::string, boost::any>::iterator iter =
binaryHeader.begin(); iter != binaryHeader.end(); iter++)
cout << any_cast<string>((*iter).first) << " is " <<
boost::any_cast<short>((*iter).second) << endl;
---------------
whereis this works perfectly(replacing <shortwith <int>):
---------------
for( map<std::string, boost::any>::iterator iter =
binaryHeader.begin(); iter != binaryHeader.end(); iter++) {
cout << any_cast<string>((*iter).first) << " is " <<
boost::any_cast<int>((*iter).second) << endl;
----------------
What is wrong ? Isn't "boost::any" supposed to take 'any' type ?
Thanks in advance
Kamran 7 1645
Kamran wrote:
Hi,
Having problem with boost and stuck.
[..]
Did you know that Boost has its own online forum? Just checking...
Kamran wrote:
Having problem with boost and stuck.
I have the following:
std::map <std::string, boost::anybinaryHeader;
and somewere else I write:
---------------
binaryHeader.insert(make_pair("job", 0));
binaryHeader.insert(make_pair("line", 0));
binaryHeader.insert(make_pair("reel", 0));
binaryHeader.insert(make_pair("Ensemble", 0));
---------------
further down in another function the following does not work:
---------------
for( map<std::string, boost::any>::iterator iter =
binaryHeader.begin(); iter != binaryHeader.end(); iter++)
cout << any_cast<string>((*iter).first) << " is " <<
boost::any_cast<short>((*iter).second) << endl;
---------------
whereis this works perfectly(replacing <shortwith <int>):
---------------
for( map<std::string, boost::any>::iterator iter =
binaryHeader.begin(); iter != binaryHeader.end(); iter++) {
cout << any_cast<string>((*iter).first) << " is " <<
boost::any_cast<int>((*iter).second) << endl;
----------------
What is wrong ? Isn't "boost::any" supposed to take 'any' type ?
For help with portions of Boost that are not part of TR1, you should
ask on the Boost User list. See this FAQ for what is on-topic here: http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
<OT>The second loop is correct because you made pairs of strings and
integers (the default type for numeric literals). If you do something
like 'make_pair( "hi", short(0) )', then the first loop should
work.</OT>
Cheers! --M
mlimber wrote:
Kamran wrote:
>>Having problem with boost and stuck. I have the following:
std::map <std::string, boost::anybinaryHeader;
and somewere else I write: --------------- binaryHeader.insert(make_pair("job", 0)); binaryHeader.insert(make_pair("line", 0)); binaryHeader.insert(make_pair("reel", 0)); binaryHeader.insert(make_pair("Ensemble", 0)); --------------- further down in another function the following does not work: --------------- for( map<std::string, boost::any>::iterator iter = binaryHeader.begin(); iter != binaryHeader.end(); iter++) cout << any_cast<string>((*iter).first) << " is " << boost::any_cast<short>((*iter).second) << endl; --------------- whereis this works perfectly(replacing <shortwith <int>): --------------- for( map<std::string, boost::any>::iterator iter = binaryHeader.begin(); iter != binaryHeader.end(); iter++) { cout << any_cast<string>((*iter).first) << " is " << boost::any_cast<int>((*iter).second) << endl; ---------------- What is wrong ? Isn't "boost::any" supposed to take 'any' type ?
For help with portions of Boost that are not part of TR1, you should
ask on the Boost User list. See this FAQ for what is on-topic here:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9
<OT>The second loop is correct because you made pairs of strings and
integers (the default type for numeric literals). If you do something
like 'make_pair( "hi", short(0) )', then the first loop should
work.</OT>
Cheers! --M
Thanks a lot. It worked. And sorry, I was not aware that there was a
mailing list for boost though I should have known.
Kamran
Thanks a lot. It worked. And sorry, I was not aware that there was a
mailing list for boost though I should have known.
you shouldn't have to sign up for a stinkin mailing list for every tool
you want help with. If I did then I'd be subscribed to several hundred
and would never get thru all the irrelevant emails. projects SHOULD use
USENET as a preferred support forum.
* noone:
>Thanks a lot. It worked. And sorry, I was not aware that there was a mailing list for boost though I should have known.
you shouldn't have to sign up for a stinkin mailing list for every tool
you want help with. If I did then I'd be subscribed to several hundred
and would never get thru all the irrelevant emails. projects SHOULD use
USENET as a preferred support forum.
<url: news://news.gmane.org/gmane.comp.lib.boost.devel>
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
On Sat, 29 Jul 2006 09:24:32 +0200, Alf P. Steinbach wrote:
* noone:
>>Thanks a lot. It worked. And sorry, I was not aware that there was a mailing list for boost though I should have known.
you shouldn't have to sign up for a stinkin mailing list for every tool you want help with. If I did then I'd be subscribed to several hundred and would never get thru all the irrelevant emails. projects SHOULD use USENET as a preferred support forum.
<url: news://news.gmane.org/gmane.comp.lib.boost.devel>
lemme rephrase, projects should allow ANONYMOUS USENET as a preferred
support forum.
* noone:
On Sat, 29 Jul 2006 09:24:32 +0200, Alf P. Steinbach wrote:
>* noone:
>>>Thanks a lot. It worked. And sorry, I was not aware that there was a mailing list for boost though I should have known. you shouldn't have to sign up for a stinkin mailing list for every tool you want help with. If I did then I'd be subscribed to several hundred and would never get thru all the irrelevant emails. projects SHOULD use USENET as a preferred support forum.
<url: news://news.gmane.org/gmane.comp.lib.boost.devel>
lemme rephrase, projects should allow ANONYMOUS USENET as a preferred
support forum.
Well, I don't know what "anonymous usenet" is and I'm an old hand.
Anyway, it's off-topic. <g>
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Rex_chaos |
last post by:
Hi all,
I am looking for a high-performance container(matrix and vector) for
numerical computation. Someone recommended the boost::multi_array. After
having looked at the documentation, I know...
|
by: Dan Trowbridge |
last post by:
He everyone,
I am just getting started with .NET and I am having a porting problem.
I get and error in code that lookssomething like this (really stripped down
but you get the idea)...
class...
|
by: MeganTSU |
last post by:
Hey yall! I am trying to get this program finished for class.... It
says that you are suppposed to write a program that will display a
check formatted out put (the output looks like a check). I got...
|
by: Jef Driesen |
last post by:
I'm trying to create a graph from an image, where pixel values are
regions labels. I have defined my graph to use lists instead of the
vectors (because I need to add/remove vertices and edges) and...
|
by: Lighter |
last post by:
#include <boost/thread/thread.hpp>
#include <iostream>
using namespace std;
using namespace boost;
void hello()
{
cout << "Hello world, I'm a thread!" << endl;
}
|
by: tkirke |
last post by:
How does one transfer a buffer object from python -c and back again
(assuming the data gets modified)?
I can't seem to get this or anything else to work, but am clueless as
to what I'm doing wrong...
|
by: TonyHa |
last post by:
Hello
I try to install boost_1_33_1 on RedHat Linux.
I have downloaded boost into /user/dtgtools/tmp and I try to install it
into
/user/dtgtools/packages/boost.
I use the following commands:...
|
by: Stephen Torri |
last post by:
Below is a class that is suppose to represent a segment of memory or a
contents of a binary image (e.g. ELF executable). I have started to read
Modern C++ Design and thought the best way to ensure...
|
by: alan |
last post by:
I have a set of classes, cell, cell_body, and cell_internal.
cell_internal is an abstract base class, intended to encapsulate
deferred computation.
cell is just a wrapped pointer around...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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,...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |