 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Ron Natalie Guest
|
Posted: Fri Jul 25, 2003 2:22 pm Post subject: Re: volatile type copy constructor |
|
|
"Gwang Sik Yoon" <gsyoon (AT) salmosa (DOT) kaist.ac.kr> wrote
| Quote: | The following code is meant to assign a volatile return value to a
variable. But the compiler can't find the seemingly correct copy
constructor. Interestingly, there's no problem in assigning a volatile
variable to a variable.
|
I think you may want an
X(const volatile&)
copy constructor. The return value is an rvalue and can't be bound
to a non-const reference.
|
|
| Back to top |
|
 |
Gwang Sik Yoon Guest
|
Posted: Mon Aug 04, 2003 8:24 am Post subject: Re: volatile type copy constructor |
|
|
"Ron Natalie" <ron (AT) sensor (DOT) com> wrote
| Quote: | "Gwang Sik Yoon" <gsyoon (AT) salmosa (DOT) kaist.ac.kr> wrote
The following code is meant to assign a volatile return value to a
variable. But the compiler can't find the seemingly correct copy
constructor. Interestingly, there's no problem in assigning a volatile
variable to a variable.
I think you may want an
X(const volatile&)
copy constructor. The return value is an rvalue and can't be bound
to a non-const reference.
|
I tried that also and failed.
Your last sentence seems to imply that
const volatile X h() {.... } ;
const volatile X var_a = h() ;
should work.
var_a is a const reference. isn't it?
However, it doesn't work either.
Am I missing or mis-interpreting something here?
Can you give me some references for your last sentece?
I have read a few books on C++ such as The C++ Programming Language,
C++ FAQs, etc, but can't remember any phrases that
say volatiles are rvalues.
Thanks for your help again. :)
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|