Path: csiph.com!usenet.pasdenom.info!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: binding reference of type =?utf-8?Q?=E2=80=98unsigned_char&?= =?utf-8?Q?=E2=80=99?= to =?utf-8?Q?=E2=80=98const?= unsigned =?utf-8?Q?ch?= =?utf-8?Q?ar=E2=80=99?= discards qualifiers Followup-To: comp.lang.c++ Date: Sun, 23 May 2021 18:11:07 -0700 Organization: None to speak of Lines: 68 Message-ID: <87y2c53phw.fsf@nosuchdomain.example.com> References: <4b3ea5a4-a02f-4cd2-9d0b-75c2f88fc721n@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: reader02.eternal-september.org; posting-host="515a578b1fbda6d2e69cf5c5ac94ed10"; logging-data="15552"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ta4tko8A2Sj4fOEBmTCDP" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) Cancel-Lock: sha1:0Umg1lmMmGrNXJttsy7UiW/GrwQ= sha1:8IXSkJlmJYuPXgN1kc44l4e+8N0= Xref: csiph.com comp.lang.c:161017 comp.lang.c++:79728 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 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 > #include > #include > > > 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 */