Login
User Name:

Password:



Register
Forgot your password?
Vote for Us!
parse description bug
Dec 15, 2017, 10:08 pm
By Remcon
Couple bugs
Dec 12, 2017, 5:42 pm
By Remcon
Bug in disarm( )
Nov 12, 2017, 6:54 pm
By GatewaySysop
Bug in will_fall( )
Oct 23, 2017, 1:35 am
By GatewaySysop
Bug in do_zap( ), do_brandish( )
Oct 18, 2017, 1:52 pm
By GatewaySysop
LOP 1.45
Author: Remcon
Submitted by: Remcon
LOP Heroes Edition
Author: Vladaar
Submitted by: Vladaar
Heroes sound extras
Author: Vladaar
Submitted by: Vladaar
6Dragons 4.3
Author: Vladaar
Submitted by: Vladaar
Memwatch
Author: Johan Lindh
Submitted by: Vladaar
Users Online
CommonCrawl, Google, Sogou, Yahoo!

Members: 0
Guests: 9
Stats
Files
Topics
Posts
Members
Newest Member
477
3,706
19,240
608
LAntorcha
Today's Birthdays
There are no member birthdays today.
Related Links
» SmaugMuds.org » 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, 1:01 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
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, 7: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, 9: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 1, 2014, 11:43 pm
Go to the top of the page
Go to the bottom of the page

Samson
Black Hand
GroupAdministrators
Posts3,639
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 >>