473,473 Members | 2,274 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Inherit from Intrinsic

First attempt:

class Blah : public int
{

};

So I began working on the next best thing:
class Blah : public IntrinsicClone<int>
{

};

And here she is:

template<class T> class IntrinsicClone
{
private:

T data;

public:
IntrinsicClone() {}

template<class R> IntrinsicClone(const R r) : data(r) { }

template<class R> T& operator=(const R r) { return data = r; }
template<class R> T& operator+=(const R r) { return data += r; }
template<class R> T& operator-=(const R r) { return data -= r; }
template<class R> T& operator*=(const R r) { return data *= r; }
template<class R> T& operator/=(const R r) { return data /= r; }
template<class R> T& operator%=(const R r) { return data %= r; }
template<class R> T& operator^=(const R r) { return data ^= r; }
template<class R> T& operator&=(const R r) { return data &= r; }
template<class R> T& operator|=(const R r) { return data |= r; }
template<class R> T& operator<<=(const R r) { return data <<= r; }
template<class R> T& operator>>=(const R r) { return data >>= r; }
template<class R> T& operator<=(const R r) { return data <= r; }
template<class R> T& operator>=(const R r) { return data >= r; }

T& operator++() { return ++data; }
T operator++(int) { return data++; }
T& operator--() { return --data; }
T operator--(int) { return data--; }
//And last but not least!
operator T()
{
return data;
}

};

Comments, questions, suggestions.
-JKop
Jul 22 '05 #1
1 1413
I've been playing with the following but can't quite seem
to get it to work. I need to make all the default operators
private.
template<class T> class IntrinsicClone
{
private:

IntrinsicClone();
IntrinsicClone(const IntrinsicClone&);
IntrinsicClone& operator=(const IntrinsicClone&);
IntrinsicClone* operator&();

public:

T data;

operator T&()
{
return data;
}

};


int main()
{
IntrinsicClone<unsigned long> k;

k = 42.5;

}

Anyone shed any light?

-JKop
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jeremy Cowles | last post by:
I have been reading a book that focuses on understanding the intrinsic types of C++ in depth. The author's mentality is this: "Understand the intrinsic types, then learn the std types as needed...
3
by: George M. Garner Jr. | last post by:
Is there an intrinsic to wrap the bswap x86 instruction. I have written a function to do this with inline assembler but I am wondering if an intrinsic wouldn't be a better solution. Regards, ...
13
by: Alek Davis | last post by:
Hi, Is it possible to access intrinsic ASP objects, such as Request, from a .NET class. Say, I have a .NET library exposed via a COM or COM+ wrapper. Can this library retrieve the request info...
5
by: Alan Ho | last post by:
What are intrinsic objects of asp.net? thx
7
by: A Traveler | last post by:
Hello all, i was just curious if anyone whos been playing with VS2005 could tell me... In javascript (and java??) you can alter the prototypes for an object in your project. I dont remember...
0
by: albean | last post by:
I I have a number of VB COM components used in ASP pages that access some intrinsic ASP objects. Basically we would get the context from COMSVCSLib and from there get the ASP Request and Response...
2
by: jason | last post by:
hello everyone, i have had a suppot ticket open with microsoft for some time to investigate a memory leak issue we are experiencing on our production web servers. the web servers host both ASP...
8
by: Thelma Lubkin | last post by:
I have finally nagged more work out of the non-profit organization that I'm trying to do volunteer work for. The following code begins a tiny form that is part of the project that I'll be...
2
by: John A Grandy | last post by:
For ASP.NET UserControls , is it possible to provide multiple overrides of the intrinsic handler methods (those for which the delegate that wires the event to the handler is built-in , such as Init...
2
by: Bryan Parkoff | last post by:
Do you know where I can find a good book how to write intrinsic function? Intrinsic function is useful to use MMX or SSE or any SIMD instruction of x86 and other machines for best portability. It...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
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...
0
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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.