return storage class and rl value specialization

  • Thread starter terminator(jam)
  • Start date
T

terminator(jam)

Since delaration of C++ the r/l-valueness of objects has been source
of confusion there are some actions that can perform on lvalues but
not on rvalues , especifically on initrinsic types .BTW the programmer
is not capable of defining special interface for classes based on the
r/l-valueness of the object(the way we do for const/volatile).Move
proposal - about Hot(rvalue) refernce - has been an attempt to get
that different behavior at reference level with the focus on
constructors.I am going to make a more general offer which may affect
the proposed syntax for rvalue references .We can assume that rvalues
have a distinct storage class (say temporary or 'return'
storage),which is different in lifetime from 'auto' storage class.We
can assume that normal automatic variables have anti-return
('~return') storage:

struct A {
A();
A(A return&);//move constructor
A(const A &);//copy constructor
void either_side();//operates on both r and l value.
void rvalue() return;//operate on rvalues.
void const_lvalue() const ~return;//operate on const lvalues.
};

struct B {
void F1();//provided for all objects
void F1() return;//specialized for rvalues

void F2();//provide for all objects
void F2() ~return;//specialized for lvalues

void F3() return;//specialized for rvalues
void F3() ~return;//specialized for lvalues
};

Since it is meaningless to declare a value as rvalue,pointers and
objects cannot be declared as rvalue but refrences can,and casting
references from r to l or the vice-versa can be performed via side
casting:

return_cast<~return&> (return_cast<return&> (object));

for further keword extentions in language I suggest separating the
prefix from cast operators and declaring them as following macros in a
popular header:

//cast.h
#ifndef CAST_H
#define CAST_H

#define static_cast static cast
#define dynamic_cast dynamic cast
#define const_cast const cast
#define reinterpret_cast do cast
#define return_cast return cast

#endif

since const , static , do and return are existing keywords ,We have
produced five compound keywords declaring only two actual keywords,
this releases the dynamic keyword for later language extention.

regards,
FM.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,817
Latest member
DicWeils

Latest Threads

Top