Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #161017

Re: binding reference of type ‘unsigned char&’ to ‘const unsigned char’ discards qualifiers

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c, comp.lang.c++
Subject Re: binding reference of type ‘unsigned char&’ to ‘const unsigned char’ discards qualifiers
Followup-To comp.lang.c++
Date 2021-05-23 18:11 -0700
Organization None to speak of
Message-ID <87y2c53phw.fsf@nosuchdomain.example.com> (permalink)
References <4b3ea5a4-a02f-4cd2-9d0b-75c2f88fc721n@googlegroups.com>

Cross-posted to 2 groups.

Followups directed to: comp.lang.c++

Show all headers | View raw


Google Groups is broken.  If you post to comp.lang.c++, it quietly drops
the "++" and posts to comp.lang.c.  (You *might* be able to write the
newsgroup name as "comp.lang.c%2b%2b"; can someone confirm that?)

I've cross-posted this reply to both newsgroups, with followups to
comp.lang.c++.  Any followups to this should go to comp.lang.c++.

(Consider using a Usenet server such as news.eternal-september.org with
a newsreader such as Thunderbird or Gnus (the latter runs under Emacs).)

(I've posted new text at the top of the quoted text to be sure it isn't
missed.  The usual convention here is for new text to go *below* quoted
text.)

M Powell <forumsmp@gmail.com> writes:
> Hi all,  thought I had a decent handle on some aspects of C++ but this one has me stomped.   I'm using an API (Driver that I cant change).   For brevity here's a snippet
>
> #include <iostream>
> #include <sstream>
> #include <string>
>
>
> template < class In, unsigned int In_depth ,
>            class Out, unsigned int Out_depth >
> class Driver {
> public :
>   bool GetFromOutputFIFO ( Out& msg_data, unsigned int & msg_size ) {
> 	//stuff
> 	return true ;
>   }
>
>   bool GetFromOutputFIFO ( const void* msg_data, unsigned int & msg_size ) {
> 	return GetFromOutputFIFO ( * (const In *) msg_data, msg_size ) ;
>   }
> };
>
> class Foo
> {
>   Driver < unsigned char, 10, unsigned char, 10 > driver ;
> public :
>   unsigned int WriteOut ( const unsigned int address, const unsigned char* buf,
> 		                  const unsigned int len, const bool send )
>   {
> 	unsigned int ll = len ;
> 	driver.GetFromOutputFIFO (  buf , ll );
> 	//driver.GetFromOutputFIFO ( const_cast < unsigned char* > ( buf ), ll );
> 	//driver.GetFromOutputFIFO
> 	//( const_cast < unsigned char* > ( const_cast < unsigned char* > ( buf ) ), ll );
>
>   }
> };
>
> int main() 
> {
> }
>
>
> The error
> error: binding reference of type ‘unsigned char&’ to ‘const unsigned char’ discards qualifiers
>
> How do I pass in buf to GetFromOutputFIFO ?
>
> Thanks in advance 

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

Back to comp.lang.c | Previous | Next | Find similar | Unroll thread


Thread

Re: binding reference of type ‘unsigned char&’ to ‘const unsigned char’ discards qualifiers Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-05-23 18:11 -0700

csiph-web