On Sunday, 11 August 2013 at 18:29:15 UTC, JS wrote:
On Sunday, 11 August 2013 at 18:18:22 UTC, Dicebot wrote:
On Sunday, 11 August 2013 at 17:03:04 UTC, JS wrote:
This is essentially what I'm doing BUT I am trying to avoid
having to repeat the exact same crap in every class because
it is
On 2013-08-11 21:08, Simen Kjaeraas wrote:
If you're looking for a no-overhead solution, then this might not be
good enough. I'm surprised that a virtual function call is fine,
though.
How about this:
interface I
{
size_t size (this T) ()
{
return __traits(classInstanceSize,
On Monday, 12 August 2013 at 11:34:25 UTC, Jacob Carlborg wrote:
On 2013-08-11 21:08, Simen Kjaeraas wrote:
If you're looking for a no-overhead solution, then this might
not be
good enough. I'm surprised that a virtual function call is
fine,
though.
How about this:
interface I
{
On 2013-08-12 17:49, JS wrote:
Sorry but this doesn't work. b is a B, not an A.
try
I a = new A;
I b = new B;
Right, forgot about the interface.
--
/Jacob Carlborg
On Monday, 12 August 2013 at 19:44:56 UTC, Jacob Carlborg wrote:
On 2013-08-12 17:49, JS wrote:
Sorry but this doesn't work. b is a B, not an A.
try
I a = new A;
I b = new B;
Right, forgot about the interface.
NP, happens to all of us. Simen's method of casting to object
seems to be
On 11.08.2013 06:25, JS wrote:
Given an object, is there a built in way to get the size of the class
the object represents? The object may be instantiated with a derived
instance of the object type, so using classInstanceSize doesn't work on
the type of the object.
I can obviously go through
On 08/11/2013 06:25 AM, JS wrote:
Given an object, is there a built in way to get the size of the class
the object represents?
Yes.
On 8/11/13, JS js.m...@gmail.com wrote:
Given an object, is there a built in way to get the size of the
class the object represents?
Try:
import core.memory;
auto size = GC.sizeOf(object);
On Sunday, 11 August 2013 at 13:40:41 UTC, Timon Gehr wrote:
On 08/11/2013 06:25 AM, JS wrote:
Given an object, is there a built in way to get the size of
the class
the object represents?
Yes.
Troll.
On Sunday, 11 August 2013 at 09:30:32 UTC, Tobias Pankrath wrote:
On 11.08.2013 06:25, JS wrote:
Given an object, is there a built in way to get the size of
the class
the object represents? The object may be instantiated with a
derived
instance of the object type, so using classInstanceSize
Is this a mathematical fact that you have proven for all
languages? I'd like to see your proof if it's not bigger than
what will fit in a post.
That's so obvious, that you should be able to come up with one
yourself. Maybe you never experienced a situation where it was
clear, but that
On Sunday, 11 August 2013 at 15:28:44 UTC, JS wrote:
On Sunday, 11 August 2013 at 13:40:41 UTC, Timon Gehr wrote:
On 08/11/2013 06:25 AM, JS wrote:
Given an object, is there a built in way to get the size of
the class
the object represents?
Yes.
Troll.
I guess he does not answer to the
Maxim Fomin:
GC.sizeOf seems to return size of allocated page which is
bigger than needed (for ex. it returns 16 for a new int which
is 4).
The object instance contains a pointer to the virtual table, so
there's a way to know what object it is. With that runtime
information it should be
On Sunday, 11 August 2013 at 15:38:04 UTC, Tobias Pankrath wrote:
Is this a mathematical fact that you have proven for all
languages? I'd like to see your proof if it's not bigger than
what will fit in a post.
That's so obvious, that you should be able to come up with one
yourself. Maybe you
On Sunday, 11 August 2013 at 16:16:26 UTC, bearophile wrote:
Maxim Fomin:
GC.sizeOf seems to return size of allocated page which is
bigger than needed (for ex. it returns 16 for a new int which
is 4).
The object instance contains a pointer to the virtual table, so
there's a way to know
On Sunday, 11 August 2013 at 16:36:53 UTC, Adam D. Ruppe wrote:
On Sunday, 11 August 2013 at 04:25:21 UTC, JS wrote:
Given an object, is there a built in way to get the size of
the class the object represents?
try this:
Object obj = new Whatever();
auto size = typeid(obj).init.length;
On Sunday, 11 August 2013 at 16:36:53 UTC, Adam D. Ruppe wrote:
On Sunday, 11 August 2013 at 04:25:21 UTC, JS wrote:
Given an object, is there a built in way to get the size of
the class the object represents?
try this:
Object obj = new Whatever();
auto size = typeid(obj).init.length;
Yes,
On Sunday, 11 August 2013 at 16:43:09 UTC, Dicebot wrote:
On Sunday, 11 August 2013 at 16:40:48 UTC, Maxim Fomin wrote:
Yes, this is answer to the question. By the way, it can be
simply
enum S = typeid(Whatever).init.length;
If exact type is statically known, no ClassInfo is required:
enum
On 08/11/2013 05:28 PM, JS wrote:
On Sunday, 11 August 2013 at 13:40:41 UTC, Timon Gehr wrote:
On 08/11/2013 06:25 AM, JS wrote:
Given an object, is there a built in way to get the size of the class
the object represents?
Yes.
Troll.
http://en.wikipedia.org/wiki/Troll_(Internet)
On Sunday, 11 August 2013 at 17:03:04 UTC, JS wrote:
For those that care, here is a snippet of what I am doing.
What are you actually going to use the number for? If you are
going to write your own New function, you'll need the init
anyway, so you aren't really paying more to get the size
On Sunday, 11 August 2013 at 17:12:48 UTC, Timon Gehr wrote:
On 08/11/2013 05:28 PM, JS wrote:
On Sunday, 11 August 2013 at 13:40:41 UTC, Timon Gehr wrote:
On 08/11/2013 06:25 AM, JS wrote:
Given an object, is there a built in way to get the size of
the class
the object represents?
Yes.
On Sunday, 11 August 2013 at 17:19:21 UTC, Adam D. Ruppe wrote:
On Sunday, 11 August 2013 at 17:03:04 UTC, JS wrote:
For those that care, here is a snippet of what I am doing.
What are you actually going to use the number for? If you are
going to write your own New function, you'll need the
On Sunday, 11 August 2013 at 17:03:04 UTC, JS wrote:
This is essentially what I'm doing BUT I am trying to avoid
having to repeat the exact same crap in every class because it
is time consuming, verbose, and error prone.
I was answering to Maxim, I don't give a fuck about your problems.
On Sunday, 11 August 2013 at 18:15:28 UTC, Timon Gehr wrote:
On 08/11/2013 07:26 PM, JS wrote:
On Sunday, 11 August 2013 at 17:12:48 UTC, Timon Gehr wrote:
On 08/11/2013 05:28 PM, JS wrote:
On Sunday, 11 August 2013 at 13:40:41 UTC, Timon Gehr wrote:
On 08/11/2013 06:25 AM, JS wrote:
Given
On Sunday, 11 August 2013 at 18:18:22 UTC, Dicebot wrote:
On Sunday, 11 August 2013 at 17:03:04 UTC, JS wrote:
This is essentially what I'm doing BUT I am trying to avoid
having to repeat the exact same crap in every class because it
is time consuming, verbose, and error prone.
I was
On Sunday, 11 August 2013 at 18:29:15 UTC, JS wrote:
THEN WHY THE FUCK DO YOU POST ON MY THREAD?
Because you are so funny when you rage and I take pleasure in
stressing someone as retarded as you ;)
Well, actually not. It was just to clarify possible misconception
by Maxim. Still feels
On 2013-08-11, 20:33, JS wrote:
I think you're missing the point to some degree(I realize there is a
diff between an object and a type, but I should be able to easily get
the class size of an object at run time regardless if the object is
typed as a base class). The code below does this,
You seem to show a certain amount of sophistication in projecting your
own attributes on others. Why not retarget that creativity to achieve
something useful?
On Sunday, 11 August 2013 at 18:33:19 UTC, JS wrote:
The code below does this, but at a cost of verbosity.
I don't see what the difference is in functionality - it looks to
me that you just reimplemented what the compiler does
automatically with typeid.
The way typeid(obj) works is similar
On Sunday, 11 August 2013 at 19:08:58 UTC, Simen Kjaeraas wrote:
On 2013-08-11, 20:33, JS wrote:
I think you're missing the point to some degree(I realize
there is a diff between an object and a type, but I should be
able to easily get the class size of an object at run time
regardless if
BTW, I hope that if you want to be added to the ignore list on my
side, you use the script and do the same. I know some will want
everyone to see their irrelevant posts but I won't see it and so
you will never get a response from me and it just clutters up the
NG and distracts from D.
On Sunday, 11 August 2013 at 19:06:07 UTC, Adam D. Ruppe wrote:
On Sunday, 11 August 2013 at 18:33:19 UTC, JS wrote:
The code below does this, but at a cost of verbosity.
I don't see what the difference is in functionality - it looks
to me that you just reimplemented what the compiler does
On Sunday, 11 August 2013 at 19:33:43 UTC, JS wrote:
If you read Simen Kjaeraas's post you will see it doesn't work
directly with interfaces, which is what I was doing.
Oh, I see it now. I think typeid(interface) gives a different set
of info.
This seems to work though:
On Sunday, 11 August 2013 at 19:58:26 UTC, Adam D. Ruppe wrote:
Oh, I see it now. I think typeid(interface) gives a different
set of info.
Thinking about it a bit more, this makes sense because an
interface is not necessarily an Object - it might also be a C++
class, or a COM object, or
On Sunday, 11 August 2013 at 20:03:27 UTC, Adam D. Ruppe wrote:
On Sunday, 11 August 2013 at 19:58:26 UTC, Adam D. Ruppe wrote:
Oh, I see it now. I think typeid(interface) gives a different
set of info.
Thinking about it a bit more, this makes sense because an
interface is not necessarily an
Given an object, is there a built in way to get the size of the
class the object represents? The object may be instantiated with
a derived instance of the object type, so using classInstanceSize
doesn't work on the type of the object.
I can obviously go through the trouble of adding a class
36 matches
Mail list logo