1)
Support the idiom:
p - static_cast<C:: *M>(p)
C is a class.
M is a data member of C (not a type).
The value of p must implicitly convert to the type of M.
If the value of p (after conversion) is the address of
the member M of some instance of C, the result
of the "expression " has type C * and is the address of
the instance of C. Otherwise, the result is undefined.
This idiom could be supported directly, or by
allowing C::*M as a new sort of pointer, that
would only have default and copy constructors,
assignment. Otherwise only usable in this
weird new overload of -.
2)
Allow
class X.Y ... ;
to indicate that class Y can only be used as the
type of data members of class X. If Y is member
of class X, X can be omitted:
class .Y ... ; 19 1180
W Karas wrote:
1)
[..]
2)
[..]
Can you perhaps explain what problems those solve (that can't be solved
now by any other means)? Thanks!
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
W Karas <wk****@yahoo.c omwrote in news:3cb466d6-76bf-4c92-ba01- 3e**********@z7 2g2000hsb.googl egroups.com:
1)
Support the idiom:
Ummm, how can this be an idiom if it's new?
>
p - static_cast<C:: *M>(p)
C is a class.
M is a data member of C (not a type).
The value of p must implicitly convert to the type of M.
If the value of p (after conversion) is the address of
the member M of some instance of C, the result
of the "expression " has type C * and is the address of
the instance of C. Otherwise, the result is undefined.
This idiom could be supported directly, or by
allowing C::*M as a new sort of pointer, that
would only have default and copy constructors,
assignment. Otherwise only usable in this
weird new overload of -.
What problem does this address?
>
2)
Allow
class X.Y ... ;
to indicate that class Y can only be used as the
type of data members of class X. If Y is member
of class X, X can be omitted:
class .Y ... ;
How is this different than:
class X
{
class Y
{
};
Y y;
};
Class Y can only be used by data members of class X.
joe
On Jul 10, 1:21 pm, Victor Bazarov <v.Abaza...@com Acast.netwrote:
W Karas wrote:
1)
[..]
2)
[..]
Can you perhaps explain what problems those solve (that can't be solved
now by any other means)? Thanks!
1)
The rational is the same as for having the
capability to get the address of a derived
class instance from the address of the
base class instance within the derived
class instance.
2)
Suppose you have in a class where one
member is an array and another
this is an intrusive linked list
container for elements of the array.
Suppose that the linked list uses
array indexes as links instead of
pointers. The implementation of
the class for the container would
be dependent on the instance being
in the class with the array. This
language feature would allow this
requirement to be express and enforced
by the compiler.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
On Jul 10, 1:45 pm, Joe Greer <jgr...@doublet ake.comwrote:
W Karas <wka...@yahoo.c omwrote in news:3cb466d6-76bf-4c92-ba01-
3e6f4392b...@z7 2g2000hsb.googl egroups.com:
1)
Support the idiom:
Ummm, how can this be an idiom if it's new?
p - static_cast<C:: *M>(p)
C is a class.
M is a data member of C (not a type).
The value of p must implicitly convert to the type of M.
If the value of p (after conversion) is the address of
the member M of some instance of C, the result
of the "expression " has type C * and is the address of
the instance of C. Otherwise, the result is undefined.
This idiom could be supported directly, or by
allowing C::*M as a new sort of pointer, that
would only have default and copy constructors,
assignment. Otherwise only usable in this
weird new overload of -.
What problem does this address?
2)
Allow
class X.Y ... ;
to indicate that class Y can only be used as the
type of data members of class X. If Y is member
of class X, X can be omitted:
class .Y ... ;
How is this different than:
class X
{
class Y
{
};
Y y;
};
Class Y can only be used by data members of class X.
(I need to amend my original proposal to say that
Y can only be used for non-static data members of X.)
In your example, this would also be possible:
void X::foo(void) { Y y; ... }
#2 and #1 are related. The idea is that member functions
of Y should know it's safe to get the address of X
from the "this" pointer (to Y).
>
joe
On Jul 10, 1:08 pm, W Karas <wka...@yahoo.c omwrote:
1)
Support the idiom:
p - static_cast<C:: *M>(p)
C is a class.
M is a data member of C (not a type).
The value of p must implicitly convert to the type of M.
If the value of p (after conversion) is the address of
the member M of some instance of C, the result
of the "expression " has type C * and is the address of
the instance of C. Otherwise, the result is undefined.
This idiom could be supported directly, or by
allowing C::*M as a new sort of pointer, that
would only have default and copy constructors,
assignment. Otherwise only usable in this
weird new overload of -.
Actually a better idiom would be:
static_cast<C:: *M>(p) - &(C::M)
yields the address (with type C *) of
the containing instance of C.
On Jul 10, 3:28 pm, W Karas <wka...@yahoo.c omwrote:
On Jul 10, 1:08 pm, W Karas <wka...@yahoo.c omwrote:
1)
Support the idiom:
p - static_cast<C:: *M>(p)
C is a class.
M is a data member of C (not a type).
The value of p must implicitly convert to the type of M.
If the value of p (after conversion) is the address of
the member M of some instance of C, the result
of the "expression " has type C * and is the address of
the instance of C. Otherwise, the result is undefined.
This idiom could be supported directly, or by
allowing C::*M as a new sort of pointer, that
would only have default and copy constructors,
assignment. Otherwise only usable in this
weird new overload of -.
Actually a better idiom would be:
static_cast<C:: *M>(p) - &(C::M)
yields the address (with type C *) of
the containing instance of C.
Another possibillity would be to simply
add a new overload of - :
C *containing_C = p - &(C::M);
Or, to appropriately scare the code
maintainer, the overloaded
- here could return a instance of the
appropriate instantiation of:
namespace std
{
template<class C>
struct CONTAINING {
C *containing; };
}
changing the above to
C* containing_C =
(p - &(C::M)).contai ning;
On Jul 10, 5:24 pm, W Karas <wka...@yahoo.c omwrote:
On Jul 10, 3:28 pm, W Karas <wka...@yahoo.c omwrote:
On Jul 10, 1:08 pm, W Karas <wka...@yahoo.c omwrote:
1)
Support the idiom:
p - static_cast<C:: *M>(p)
C is a class.
M is a data member of C (not a type).
The value of p must implicitly convert to the type of M.
If the value of p (after conversion) is the address of
the member M of some instance of C, the result
of the "expression " has type C * and is the address of
the instance of C. Otherwise, the result is undefined.
This idiom could be supported directly, or by
allowing C::*M as a new sort of pointer, that
would only have default and copy constructors,
assignment. Otherwise only usable in this
weird new overload of -.
Actually a better idiom would be:
static_cast<C:: *M>(p) - &(C::M)
yields the address (with type C *) of
the containing instance of C.
Another possibillity would be to simply
add a new overload of - :
C *containing_C = p - &(C::M);
Or, to appropriately scare the code
maintainer, the overloaded
- here could return a instance of the
appropriate instantiation of:
namespace std
{
template<class C>
struct CONTAINING {
C *containing; };
}
changing the above to
C* containing_C =
(p - &(C::M)).contai ning;
There is, of course, a solution to this problem
using reinterpret_cas t<char *. The de facto
portability of this solution is very high, even
though the Standard does not guarantee the
portability of it. Is the fact that this de
facto solution exists a significant reason
why the language has not been changed to
address the issue?
On Jul 11, 4:21 pm, Juha Nieminen <nos...@thanks. invalidwrote:
I apologize for shamelessly put this here, but it seemed to be a
proper place... :)
I have compiled my own C++ wishlist, if anyone is interested:
http://warp.povusers.org/cpluspluswishlist.html
Well, my first wish would be that compilers would actually
implement the features we've got (e.g. like export).
--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: P.C. |
last post by:
Hi
My son like many youngsters been around computers, fast online games, he
acturly for main part learned to read and write ,beside his second language
english , and may I say he is quite good at it age 15 , but as some of you
know, 3D games also offer edditors and script options , or rather
programming choppers and dust clouds in scenes.
Now beside my bad english, my problem is, that I like him to learn decent
programming ------- sure...
|
by: Pavils Jurjans |
last post by:
Hello,
I have a fairly complex project with server-side written in C# (.NET),
and client-side heavily relying on the presence on
JavaScript-compatible scripting engine. One of the features thie
project utilizes is "virtual POST", ie, client side submits the data
to the server side, using Microsoft.XMLHTTP ActiveX Object (in MSIE),
or XMLHttpRequest class in Mozilla, and when the server returns reply,
processes it in client side to run...
|
by: Michael B Allen |
last post by:
Is it considered a bad idea to use a C99 only feature? It has been almost
6 years right? Specifically I'm interested in variadic macros. All of
my code is C89 (or less) except for my debugging macros.
Thanks,
Mike
|
by: Servé Lau |
last post by:
I've read the new features that are coming to the next VC and they all sound
fine.
But I was missing new standard C++ features, will the features like export
still not be implemented?
What about C features like designated initializers?
struct X { int x; int y; };
X x = { .x = 2, .y = 3 };
|
by: aron t |
last post by:
Hi,
I am good php programmer and want to learn asp.net.
Can someone tell me what are the best and the worst features of ASP.NET?
thanks
| |
by: Sandy |
last post by:
Hello -
I have developed the world's ugliest website -- functions well, but it
leaves a lot to be desired aesthetically.
What are the recommended web graphics programs to integrate with Visual
Studio projects? I don't want to just go out and buy something without
knowing it works well with VS.
Also, how would you integrate it? Just copy and paste stuff?
|
by: Fister |
last post by:
I'm reading Professional C# (Wrox) and stumbled across:
"Some features are supported by.NET but not by C#, and you might be surprised
to learn that some features of the C# language are not supported by .NET
(for example, some instances of operator overloading)!"
How can some features be supported by C# and not .NET? Are there other features
than operator overloading and could someone please supply an example?
/ Fister
|
by: bearophileHUGS |
last post by:
I often use Python to write small programs, in the range of 50-500
lines of code. For example to process some bioinformatics data,
perform some data munging, to apply a randomized optimization
algorithm to solve a certain messy problem, and many different things.
For that I often use several general modules that I have written, like
implementation of certain data structures, and small general "utility"
functions/classes, plus of course...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |