473,385 Members | 1,875 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,385 software developers and data experts.

complex setters implemented differently between Linux and Windows

This might not be the right place for this post, but maybe I can get a
clarification on
what the C++ standard says.
g++ (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)
MS VC++ (2003): Version 7.1.3088
I have created a wrapper for the complex double so that I can forward
declare it
in other classes. Here is what I have had to do in my setters:
//-------------------------------------------------------------------------
inline
double ComplexDouble::real(double realPart)
//-------------------------------------------------------------------------
{
#ifdef WIN32
return impl_.real(realPart);
#else //LINUX
return ( impl_.real() = realPart );
#endif
}

//-------------------------------------------------------------------------
inline
double ComplexDouble::imag(double imagPart)
//-------------------------------------------------------------------------
{
#ifdef WIN32
return impl_.imag(imagPart);
#else //LINUX
return ( impl_.imag() = imagPart );
#endif
}
For some reason my version of g++ returns a writable reference as
opposed to passing the
parameter to set in as a method argument. I am not sure here but I
believe that VC++ is
implementing the standard correctly. Could this be a conflict with
the C standard or
something? In my experience, g++ usually wins the "closer to C++
standard" battles
but it does NOT appear to be the case here.

Thanks in advance,
Liam

Sep 2 '08 #1
2 1179
liam_herron wrote:
This might not be the right place for this post, but maybe I can get a
clarification on
what the C++ standard says.
g++ (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)
MS VC++ (2003): Version 7.1.3088
I have created a wrapper for the complex double so that I can forward
declare it
in other classes. Here is what I have had to do in my setters:
//-------------------------------------------------------------------------
inline
double ComplexDouble::real(double realPart)
//-------------------------------------------------------------------------
{
#ifdef WIN32
return impl_.real(realPart);
#else //LINUX
return ( impl_.real() = realPart );
#endif
}
Both are wrong. The current standard mandates, that real and imag are
declared as this:
template<class T>
class complex {
....
T real() const;
T imag() const;
....
};
Sep 2 '08 #2
On Sep 2, 3:52*pm, Marco Manfredini <ok_nospam...@phoyd.netwrote:
liam_herron wrote:
This might not be the right place for this post, but maybe I can get a
clarification on
what the C++ standard says.
g++ (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)
MS VC++ (2003): *Version 7.1.3088
I have created a wrapper for the complex double so that I can forward
declare it
in other classes. *Here is what I have had to do in my setters:
//-------------------------------------------------------------------------
inline
double ComplexDouble::real(double realPart)
//-------------------------------------------------------------------------
{
#ifdef WIN32
return impl_.real(realPart);
#else //LINUX
return ( impl_.real() = realPart );
#endif
}

Both are wrong. The current standard mandates, that real and imag are
declared as this:
template<class T>
class complex {
...
T real() const;
T imag() const;
...

};
But the next standard will require it {real|imag}(T) (in addition to
being layout compatible with C complex and T[2]). See the resolution
to the standard library issue 387.

GCC standard library implements an older proposed resolution of the
issue, and probably retains it for ABI reasons.

HTH,

--
gpd

Sep 2 '08 #3

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

Similar topics

26
by: Nige | last post by:
I'm a complete novice to JS. I want to insert the date and time into a document in the format: WB-MMDDHHmm Where: WB- is a fixed string prefix (the whole string is a reference number) MM...
32
by: kelvSYC | last post by:
I'm familiar with get and set function paradigms from Java, but what's the recommended design for such in C++? Should it be like so: foo& getFoo(); void setFoo(foo& f); or like so: foo&...
2
by: Lachlan Hunt | last post by:
Hi, In JavaScript 1.5, objects can use special getter and setter functions for properties. However, these only seem to be implemented in Gecko and, AFAICT, don't seem to be part of ECMAScript. ...
2
by: Wei Wang | last post by:
Greetings, I find the JavaScript's Object.prototype and getter/setter mechanism very nice. However, I need some help with extending an object with getters/setters in the derived class. For...
116
by: Mike MacSween | last post by:
S**t for brains strikes again! Why did I do that? When I met the clients and at some point they vaguely asked whether eventually would it be possible to have some people who could read the data...
8
by: Steve Jorgensen | last post by:
Mailing List management is a good example of a case where my conundrum arises. Say there is a m-m relationship between parties and groups - anyone can be a member of any combintation of groups. ...
112
by: mystilleef | last post by:
Hello, What is the Pythonic way of implementing getters and setters. I've heard people say the use of accessors is not Pythonic. But why? And what is the alternative? I refrain from using them...
4
by: rn5a | last post by:
A MS-Access DB has 3 tables - Teacher, Class & TeacherClass. The Teacher table has 2 columns - TeacherID & TeacherName (TeacherID being the primary key). The Class table too has 2 columns - ClassID...
9
by: kumarchi | last post by:
hello: I wrote a simple program which does simple math loop and I am testing under dual core processor systm1: intel dual core laptop ; windows xp os when I spawn of two threads in windows...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.