multi_index::composite_key with char[]
Hi,All: When I use the multi_index::composite_key with char[],I meet a error,when find a element。It seems to the make_tuple can't support the char[].Because the char[] more faster the std::string。So our project choose char[] as the column instead of std::string.So How should I do -- View this message in context: http://boost.2283326.n4.nabble.com/multi-index-composite-key-with-char-tp467... Sent from the Boost - Users mailing list archive at Nabble.com.
leyiliu <595657419 <at> qq.com> writes:
Hi,All: When I use the multi_index::composite_key with char[],I meet a error,when find a element。It seems to the make_tuple can't support the char[].Because the char[] more faster the std::string。So our project choose char[] as the column instead of std::string.So How should I do
Hi leyiliu,
I'm not totally sure I'm getting your question, so allow to me to
make a guess:
I assume you have something like
struct X
{
int x;
char str[20];
};
using multi_index_t=multi_index_container<
X,
indexed_by<
ordered_unique<
composite_key<
X,
member
CoreStruct.h http://boost.2283326.n4.nabble.com/file/n4679888/CoreStruct.h
TypeDef.h http://boost.2283326.n4.nabble.com/file/n4679888/TypeDef.h
this is my code file
t_ac_client_basic_set testSet;
pk_t_ac_client_basic_Index test = testSet.get
leyiliu <595657419 <at> qq.com> writes:
CoreStruct.h <http://boost.2283326.n4.nabble.com/file/n4679888/ CoreStruct.h> TypeDef.h http://boost.2283326.n4.nabble.com/file/n4679888/TypeDef.h
this is my code file
t_ac_client_basic_set testSet; pk_t_ac_client_basic_Index test = testSet.get
; test.find(std::make_tuple("KS", "1")); How can I modify to right
Hi leyiliu,
I'd suggest you don't remove the conversation context when replying to
the list, so that the conversation can be more easily followed by
potential reades. Useful info on posting guidelines at
http://www.boost.org/community/policy.html
As for your question, I've reviewed the code you provide and seemingly
you're taking my advice of providing ad-hoc hash and equality functors
taking const char* rather than char[21], so in principle everything
looks right. What exact problem/error are you getting?
PS: the line
pk_t_ac_client_basic_Index test = testSet.get
Joaquin M LópezMuñoz wrote
leyiliu <595657419 <at> qq.com> writes:
CoreStruct.h <http://boost.2283326.n4.nabble.com/file/n4679888/
> CoreStruct.h>
TypeDef.h <http://boost.2283326.n4.nabble.com/file/n4679888/TypeDef.h>
this is my code file
t_ac_client_basic_set testSet; pk_t_ac_client_basic_Index test = testSet.get
; test.find(std::make_tuple("KS", "1")); How can I modify to right
Hi leyiliu,
I'd suggest you don't remove the conversation context when replying to the list, so that the conversation can be more easily followed by potential reades. Useful info on posting guidelines at
http://www.boost.org/community/policy.html
As for your question, I've reviewed the code you provide and seemingly you're taking my advice of providing ad-hoc hash and equality functors taking const char* rather than char[21], so in principle everything looks right. What exact problem/error are you getting?
PS: the line
pk_t_ac_client_basic_Index test = testSet.get
should be pk_t_ac_client_basic_Index& test = testSet.get
(note the &). Is this related to your problem? Joaquín M López Muñoz Telefónica _______________________________________________ Boost-users mailing list
Boost-users@.boost
I follow your suggest,define the set like this:
typedef boost::multi_index_container<
t_ac_client_basic,
boost::multi_index::indexed_by<
boost::multi_index::ordered_non_unique<
boost::multi_index::tag
leyiliu <595657419 <at> qq.com> writes:
I follow your suggest,define the set like this:
typedef boost::multi_index_container< t_ac_client_basic, boost::multi_index::indexed_by<
boost::multi_index::ordered_non_unique< boost::multi_index::tag
, boost::multi_index::composite_key< t_ac_client_basic, boost::multi_index::member , boost::multi_index::member >, boost::multi_index::composite_key_compare< std::less , std::less > > > t_ac_client_basic_set;
I get a error,when add this code pk_t_ac_client_basic_Index& test = testSet.get
; : error C3867: “boost::multi_index::multi_index_container [...] ::get”: 函数调用缺少参数列表;请使 [...]
I can't read Chinese, but Google Translate suggests
the compiler is complaining about missing args to get,
which is indeed the problem:
testSet.get
Joaquín M López Munoz wrote
leyiliu <595657419 <at> qq.com> writes:
I follow your suggest,define the set like this:
typedef boost::multi_index_container< t_ac_client_basic, boost::multi_index::indexed_by<
boost::multi_index::ordered_non_unique< boost::multi_index::tag
, boost::multi_index::composite_key< t_ac_client_basic, boost::multi_index::member<t_ac_client_basic, char[21], > &t_ac_client_basic::LCcode >, boost::multi_index::member<t_ac_client_basic, char[21], > &t_ac_client_basic::ClientID > >, boost::multi_index::composite_key_compare< std::less , std::less > > > t_ac_client_basic_set;
I get a error,when add this code pk_t_ac_client_basic_Index& test = testSet.get
; : error C3867: “boost::multi_index::multi_index_container [...] ::get”: 函数调用缺少参数列表;请使 [...] I can't read Chinese, but Google Translate suggests the compiler is complaining about missing args to get, which is indeed the problem:
testSet.get
; should be
testSet.get
(); Joaquín M López Muñoz Telefónica _______________________________________________ Boost-users mailing list
Boost-users@.boost
Sorry,Long time no see. Follow you suggest,I can insert element into the container.But the find() is also a problem. *test.find(std::make_tuple("KS", "1")); *. thanks a lot -- View this message in context: http://boost.2283326.n4.nabble.com/multi-index-composite-key-with-char-tp467... Sent from the Boost - Users mailing list archive at Nabble.com.
leyiliu <595657419 <at> qq.com> writes:
leyiliu <595657419 <at> qq.com> writes:
I follow your suggest,define the set like this:
typedef boost::multi_index_container< t_ac_client_basic, boost::multi_index::indexed_by<
boost::multi_index::ordered_non_unique< boost::multi_index::tag
, boost::multi_index::composite_key< t_ac_client_basic, boost::multi_index::member<t_ac_client_basic, char[21], > &t_ac_client_basic::LCcode >, boost::multi_index::member<t_ac_client_basic, char[21], > &t_ac_client_basic::ClientID > >, boost::multi_index::composite_key_compare< std::less , std::less > > > t_ac_client_basic_set;
Sorry,Long time no see. Follow you suggest,I can insert element into the container.But the find() is also a problem. *test.find(std::make_tuple("KS", "1")); *.
thanks a lot
Oh, my bad. std::less
participants (3)
-
Joaquin M López Muñoz
-
Joaquín M López Munoz
-
leyiliu