R
Rahul Mathur
All,
I have having Boost boost::unordered_map nested map calling boost::unordered_map which calls std::map finally.
The LHS (towards RHS) side key for first boost::unordered_map is 'int' typefollowed by next key being char buffer value of size 10, and key for std::map being again a char buffer value of size 10. So the boost::unordered_maphas nested map internally.
I have to insert the char buffer of size 10 (value being either 'ORANGE' orORD123 as test case) into nested std:air as defined below. After inserting, I have to search or find the value from char buffer of size 10.
The code as compiled on Linux is -
----
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <boost/unordered_map.hpp>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
#if 0
#pragma pack(push, 2)
struct BookKeeping {
int ABCD;
char Apple_ID [10];
char Apple_NAME[10];
int Price;
int Number;
};
#pragma pack(pop)
#endif
class Name { // buffer of size 10
char str[10];
public:
Name() {
strcpy(str, "");
}
Name(char *s) {
strcpy(str, s);
}
char *get() {
return str;
}
};
bool operator<(Name a, Name b)
{
return strcmp(a.get(), b.get()) < 0;
}
#pragma pack(push, 2)
struct BookKeeping {
int ABCD;
Name Apple_ID;
Name Apple_NAME;
int Price;
int Number;
};
#pragma pack(pop)
BookKeeping *_bkkping;
typedef boost::unordered_map< int, boost::unordered_map< Name, std::map< Name, int > > > _uordmap; // nested boost::unordered_map
class BkKping {
private:
_uordmap * uordmap;
typedef boost::unordered_map< int, boost::unordered_map< Name, std::map< Name, int > > >::iterator _itr_1;
typedef boost::unordered_map< Name, std::map< Name, int > >::iterator _itr_2;
typedef std::map< Name, int >::iterator _itr_3;
public:
BkKping () {
uordmap = new _uordmap ();
}
void Apple ( int abcd, const char * Apple_ID_, const char * Color_, intPrice_ );
~BkKping () {
delete uordmap;
}
};
void BkKping::Apple ( int abcd, const char * Apple_ID_, const char * Color_, int Price_ ) {
uordmap->insert( std:air< int, std:air< Name, std:air< Name, BookKeeping &> > > ( _bkkping->ABCD , _bkkping->Apple_ID, _bkkping->Apple_NAME, *_bkkping) ); // nested std:air<> insertion
}
int main () {
int abcd;
const char * Apple_ID_;
const char * Color_;
int Price_;
BkKping book;
book.Apple( abcd, Apple_ID_, Color_, Price_);
}
-----
The error message is -
---
hello.cpp: In member function âvoid BkKping::Apple(int, const char*, const char*, int)â:
hello.cpp:76: error: no matching function for call to âstd:air<int, std:air<Name, std:air<Name, BookKeeping&> > >:air(int&, Name&, Name&, BookKeeping&)â
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:83: note: candidates are: std:air<_T1, _T2>:air(const _T1&, const _T2&) [with _T1 = int, _T2 = std:air<Name, std:air<Name, BookKeeping&> >]
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:79: note: std:air<_T1, _T2>:air() [with _T1 = int, _T2 = std:air<Name, std:air<Name, BookKeeping&> >]
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:68: note: std:air<int, std:air<Name, std:air<Name, BookKeeping&> > >:air(const std:air<int, std:air<Name, std:air<Name, BookKeeping&> > >&)
--
I have created a class buffer to read size 10.
Please help.
P.S: No issue with Boost compilation, simply looking for proper semantic call for nested std:air<>.
I have having Boost boost::unordered_map nested map calling boost::unordered_map which calls std::map finally.
The LHS (towards RHS) side key for first boost::unordered_map is 'int' typefollowed by next key being char buffer value of size 10, and key for std::map being again a char buffer value of size 10. So the boost::unordered_maphas nested map internally.
I have to insert the char buffer of size 10 (value being either 'ORANGE' orORD123 as test case) into nested std:air as defined below. After inserting, I have to search or find the value from char buffer of size 10.
The code as compiled on Linux is -
----
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <boost/unordered_map.hpp>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
#if 0
#pragma pack(push, 2)
struct BookKeeping {
int ABCD;
char Apple_ID [10];
char Apple_NAME[10];
int Price;
int Number;
};
#pragma pack(pop)
#endif
class Name { // buffer of size 10
char str[10];
public:
Name() {
strcpy(str, "");
}
Name(char *s) {
strcpy(str, s);
}
char *get() {
return str;
}
};
bool operator<(Name a, Name b)
{
return strcmp(a.get(), b.get()) < 0;
}
#pragma pack(push, 2)
struct BookKeeping {
int ABCD;
Name Apple_ID;
Name Apple_NAME;
int Price;
int Number;
};
#pragma pack(pop)
BookKeeping *_bkkping;
typedef boost::unordered_map< int, boost::unordered_map< Name, std::map< Name, int > > > _uordmap; // nested boost::unordered_map
class BkKping {
private:
_uordmap * uordmap;
typedef boost::unordered_map< int, boost::unordered_map< Name, std::map< Name, int > > >::iterator _itr_1;
typedef boost::unordered_map< Name, std::map< Name, int > >::iterator _itr_2;
typedef std::map< Name, int >::iterator _itr_3;
public:
BkKping () {
uordmap = new _uordmap ();
}
void Apple ( int abcd, const char * Apple_ID_, const char * Color_, intPrice_ );
~BkKping () {
delete uordmap;
}
};
void BkKping::Apple ( int abcd, const char * Apple_ID_, const char * Color_, int Price_ ) {
uordmap->insert( std:air< int, std:air< Name, std:air< Name, BookKeeping &> > > ( _bkkping->ABCD , _bkkping->Apple_ID, _bkkping->Apple_NAME, *_bkkping) ); // nested std:air<> insertion
}
int main () {
int abcd;
const char * Apple_ID_;
const char * Color_;
int Price_;
BkKping book;
book.Apple( abcd, Apple_ID_, Color_, Price_);
}
-----
The error message is -
---
hello.cpp: In member function âvoid BkKping::Apple(int, const char*, const char*, int)â:
hello.cpp:76: error: no matching function for call to âstd:air<int, std:air<Name, std:air<Name, BookKeeping&> > >:air(int&, Name&, Name&, BookKeeping&)â
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:83: note: candidates are: std:air<_T1, _T2>:air(const _T1&, const _T2&) [with _T1 = int, _T2 = std:air<Name, std:air<Name, BookKeeping&> >]
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:79: note: std:air<_T1, _T2>:air() [with _T1 = int, _T2 = std:air<Name, std:air<Name, BookKeeping&> >]
/usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stl_pair.h:68: note: std:air<int, std:air<Name, std:air<Name, BookKeeping&> > >:air(const std:air<int, std:air<Name, std:air<Name, BookKeeping&> > >&)
--
I have created a class buffer to read size 10.
Please help.
P.S: No issue with Boost compilation, simply looking for proper semantic call for nested std:air<>.