Login
User Name:

Password:



Register

Forgot your password?
void nanny_get_new_race -- comm.c
Mar 13, 2025 7:08 am
By Elwood
IPv6
Jan 25, 2025 10:45 pm
By Samson
mudstrlcpy and mudstrlcat
Jan 18, 2025 5:23 pm
By Samson
I3 and IMC
Jan 17, 2025 9:35 pm
By Samson
AFKMud 2.5.1
Jan 17, 2025 2:22 pm
By Samson
SWFotEFUSS 1.5.3
Author: Various
Submitted by: Samson
SWRFUSS 1.4.3
Author: Various
Submitted by: Samson
SmaugFUSS 1.9.8
Author: Various
Submitted by: Samson
AFKMud 2.5.2
Author: AFKMud Team
Submitted by: Samson
SmaugFUSS 1.9.7
Author: Various
Submitted by: Samson
Users Online
Anthropic, AhrefsBot, Amazonbot, Google

Members: 0
Guests: 22
Stats
Files
Topics
Posts
Members
Newest Member
507
3,812
19,722
591
TracySpencer

» 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,707
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 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 #3 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,707
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 >>