Login
User Name:

Password:



Register

Forgot your password?
do_owhere recursive
Author: Khonsu
Submitted by: Khonsu
Changes list / Addchange
Author: Khonsu
Submitted by: Khonsu
6Dragons mp3 sound pack
Author: Vladaar
Submitted by: Vladaar
AFKMud 2.2.3
Author: AFKMud Team
Submitted by: Samson
SWFOTEFUSS 1.5
Author: Various
Submitted by: Samson
Users Online
AhrefsBot, Google, Bing

Members: 0
Guests: 20
Stats
Files
Topics
Posts
Members
Newest Member
489
3,791
19,644
596
Elwood

Today's Birthdays
There are no member birthdays today.
» SmaugMuds » Codebases » AFKMud Support & Development » Compile error with std::bitse...
Forum Rules | Mark all | Recent Posts

Compile error with std::bitset and strings
< Newer Topic :: Older Topic >

Pages:<< prev 1 next >>
Post is unread #1 Nov 1, 2014 3:01 pm   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Figured since I was of a mind to be fixing stuff up I'd get the Smaug 1.8 variables code to actually work right in AFKMud. I've run into one last small problem though.

arthmoor@boralis:~/afkmud/src$ make
Building AFKMud....
make -j2 -s afkmud
  Compiling o/variables.o....
variables.cpp: In function ‘void fread_variable(char_data*, FILE*)’:
variables.cpp:587:39: error: no match for call to ‘(std::bitset<128ul>) (std::string&)’
                pvd->varflags( varbits );
                                       ^
make[1]: *** [o/variables.o] Error 1
make: *** [all] Error 2
arthmoor@boralis:~/afkmud/src$


That error is generated from this code:
         case 'F':
            if( !str_cmp( word, "Flags" ) )
            {
               string varbits;

               fread_string( varbits, fp );
               pvd->varflags( varbits );

               break;
            }
            break; 


According to http://www.cplusplus.com/reference/bitset/bitset/bitset/ I should be able to assign a std::bitset value via a string. Obviously the compiler disagrees, so I'm wondering what I'm missing here. It's the last hurdle left to overcome for this to compile all the way through.

Post is unread #2 Nov 1, 2014 9:38 pm   
Go to the top of the page
Go to the bottom of the page

Guest - (Unregistered)

 
Everytime someone leaves the mud community, They bring you back in! Or was that the Godfather movie? Welcome back Samson!

Post is unread #3 Nov 1, 2014 11:41 pm   
Go to the top of the page
Go to the bottom of the page

Caius
Magician
GroupMembers
Posts132
JoinedJan 29, 2006

 

pvd->varflags( varbits );



You're attempting to call operator() here, which bitset doesn't have. You can't actually assign strings to a bitset. You can, however, construct one from a string. So you can do the following:

pvd->varflags = std::bitset<128ul>( varbits );

Post is unread #4 Nov 2, 2014 1:43 am   
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,685
JoinedJan 1, 2002

 
Constructing one from a string is exactly what I was after, and that worked. So thanks. No more compile failure :)

I just hope it actually assigns them in the same order the characters in the string are written, cause there's conflicting information out there saying I may or may not need to reverse the string before sending it to the bitset constructor.

Pages:<< prev 1 next >>