473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

forcing c++ to use an overloaded method

Hi,

I need to write out a 1d array of 2d arrays (the structures for each
are custom, a 3d structure is defined but not suitable for my use for a
number of reasons).

Templated routines exist for writing out multi2d<T> and multi1d<T>,
hence writing multi2d<multi1d<T>> is possible, although fails for some
unknown reason. There is a multi3d<T> writer, but like I said...

Is it possible to define my own write routine which will write out a
multi2d<multi1d<T>> yet NOT have the compiler (g++) complain that there
is an ambiguity introduced by the already existing multi2d<T> and
multi1d<T> writers combined? I want to call it the same (i.e. write)
and pass the same arguments, to keep a consistency --- this is a large
project so any hacked solutions tend to get kicked out when the
branches merge [even this solution might be too hacked!!].

Cheers,
chris

May 31 '06 #1
3 1661
On 2006-05-31 22:21, mr**********************@googlemail.com wrote:
Hi,

I need to write out a 1d array of 2d arrays (the structures for each
are custom, a 3d structure is defined but not suitable for my use for a
number of reasons).

Templated routines exist for writing out multi2d<T> and multi1d<T>,
hence writing multi2d<multi1d<T>> is possible, although fails for some
unknown reason. There is a multi3d<T> writer, but like I said...

Is it possible to define my own write routine which will write out a
multi2d<multi1d<T>> yet NOT have the compiler (g++) complain that there
is an ambiguity introduced by the already existing multi2d<T> and
multi1d<T> writers combined? I want to call it the same (i.e. write)
and pass the same arguments, to keep a consistency --- this is a large
project so any hacked solutions tend to get kicked out when the
branches merge [even this solution might be too hacked!!].


I'm not exactly sure what you are getting at (getting late over here)
but if you want to make your own implementation of the template routines
mentioned above and be sure that your's are called you could place them
in a separate namespace and explicitly calling these. I believe that you
could then do something like

using my_space::multi2d;
using my_space::multi1d;

and you wouldn't need to prefix each call since this would tell the
compiler that it's your version you want.

Erik Wikström
--
"I have always wished for my computer to be as easy to use as my
telephone; my wish has come true because I can no longer figure
out how to use my telephone" -- Bjarne Stroustrup
May 31 '06 #2
mr**********************@googlemail.com wrote:
Hi,

I need to write out a 1d array of 2d arrays (the structures for each
are custom, a 3d structure is defined but not suitable for my use for a
number of reasons).

Templated routines exist for writing out multi2d<T> and multi1d<T>,
hence writing multi2d<multi1d<T>> is possible, although fails for some
unknown reason. There is a multi3d<T> writer, but like I said...

Is it possible to define my own write routine which will write out a
multi2d<multi1d<T>> yet NOT have the compiler (g++) complain that there
is an ambiguity introduced by the already existing multi2d<T> and
multi1d<T> writers combined? I want to call it the same (i.e. write)
and pass the same arguments, to keep a consistency --- this is a large
project so any hacked solutions tend to get kicked out when the
branches merge [even this solution might be too hacked!!].


I'm afraid you are going to have to be more clear on exactly what is
and is not working. I've written the kind of code you seem to be
describing in both ways, and had it work. Producing a small example of
code which does not work would probably both help you understand the
problem, and help us fix it.

Chris

May 31 '06 #3

mr**********************@googlemail.com wrote:
Hi,

I need to write out a 1d array of 2d arrays (the structures for each
are custom, a 3d structure is defined but not suitable for my use for a
number of reasons).

Templated routines exist for writing out multi2d<T> and multi1d<T>,
hence writing multi2d<multi1d<T>> is possible, although fails for some
unknown reason.
Probaly a very trivial one, "maximum-munch". >> is a left-shift. It's a
single
token, not two > > tokens. If you add a space between the two
characters,
it will probably work. For the same reason, >>> and >>>> are two
tokens,
Is it possible to define my own write routine which will write out a
multi2d<multi1d<T>> yet NOT have the compiler (g++) complain that there
is an ambiguity introduced by the already existing multi2d<T> and
multi1d<T> writers combined?


How do we know? You haven't shown us a bit of code.

If you just give your writer a unique name, and call it by that unique
name
- not overloaded in any sense - it will just work. Just use a GUID in
the
name if you really want it to be sure it's unique.

HTH,
Michiel Salters

Jun 1 '06 #4

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

Similar topics

1
by: John M | last post by:
Hello All, The code below is something I have been working on and just can't get past. I know it must be very simple but here goes. The Form Method line text is invisible on browers, but still...
44
by: bahadir.balban | last post by:
Hi, What's the best way to implement an overloaded function in C? For instance if you want to have generic print function for various structures, my implementation would be with a case...
1
by: Alex Zhitlenok | last post by:
Hi, My question is how to resolve in C# ambiguous overloaded operators? Let say, I have two unrelated classes A and B, each one implements overloaded operator + with the first parameter of type...
10
by: john bailo | last post by:
Can a web method be overloaded? To support varying numbers of input parameters?
3
by: cybertof | last post by:
Hello, Is it possible in C# to have 2 overloaded functions with - same names - same parameters - different return type values If no, is it possible in another language ?
2
by: Saradhi | last post by:
how to create a delegate for a overloaded method? Thanks a Lot -SARADHI
1
by: Alan | last post by:
Is there a way in C# to have the compiler enforce that users use Resource Strings? Say I have a logging subsystem, and I want make sure that the only string values that get logged come from a...
9
by: Lawrence Krubner | last post by:
Possibly a dumb question but is type hinting allowed with overloaded methods? Can one class have these two methods? public function doSelect(Criteria $c) { // some code here } public...
3
by: sam.barker0 | last post by:
Hi, I have designed a class with an overloaded = operator. The problem is that whenever I invoke the method like const myclass<charastring=another_object;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
tracyyun
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...
0
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...

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.