C C++ Programming Lessons
Re: iterators in sets - should they be const?
I deal with this issue here: [link]
/Leigh
/Leigh
Re: c++ programmers' salaries
[ ... ]
It would indeed be lamentable if it were true, it isn't:
[link]
It would appear that I personally fall a bit short of the arithmetic mean :-/
It would indeed be lamentable if it were true, it isn't:
[link]
It would appear that I personally fall a bit short of the arithmetic mean :-/
Re: Does a function know where it was called from?
backtrace() and backtrace_symbols() are documented glibc functions.
Bolt them together with gcc's abi::__cxa_demangle(), and you can come up
with a fairly reasonable stack dump.
Bolt them together with gcc's abi::__cxa_demangle(), and you can come up
with a fairly reasonable stack dump.
Re: Some errors in MIT's intro C++ course
Alf P. Steinbach /Usenet ha scritto:
You mean because of camelCase or because of the verb?
(The lecture notes are quite bad, indeed.)
You mean because of camelCase or because of the verb?
(The lecture notes are quite bad, indeed.)
Re: Does a function know where it was called from?
main uses I can think of are mostly for debugging...
one strategy I have used, although a little more limited and
special-purpose, is to make use of macros which remap calls.
say:
void fooFunc_lln(char *fname, int lnum)
{
//called from <fname>:<lnum>
GCC also provides __FUNC__, but this is non-standard (or, at least, they are
one strategy I have used, although a little more limited and
special-purpose, is to make use of macros which remap calls.
say:
void fooFunc_lln(char *fname, int lnum)
{
//called from <fname>:<lnum>
GCC also provides __FUNC__, but this is non-standard (or, at least, they are
Re: Does a function know where it was called from?
yep.
however, some non-standard means exist, but depend some on OS, compiler, and
compiler settings.
for, example, it is usually possible to perform a backtrace on most 32-bit
x86 system, but some compilers were "clever" in their optimizations, and
essentially tend to break the ability to automatically perform a backtrace.
however, some non-standard means exist, but depend some on OS, compiler, and
compiler settings.
for, example, it is usually possible to perform a backtrace on most 32-bit
x86 system, but some compilers were "clever" in their optimizations, and
essentially tend to break the ability to automatically perform a backtrace.
Re: how to organize my files/projects properly?
I understand that point of view; I just don't think it's worth the
effort, given the negative effects of doing so. Remember that this
something /you/ both create and use; it isn't a third-party library.
That's a much better description, and I kind of agree. But my gut
feeling is that you're more likely to have foo/util and bar/util
effort, given the negative effects of doing so. Remember that this
something /you/ both create and use; it isn't a third-party library.
That's a much better description, and I kind of agree. But my gut
feeling is that you're more likely to have foo/util and bar/util
Re: Exceptions, Go to Hell!
I've been following this thread with a sense of dread, mostly because
I've seen this pop up several times and the same rehashed arguments
are given. Counter example to your claims:
1- Library should throw on every pre-condition violation. Sometimes
this is overly expensive or impractical to calculate. My favorite
I've seen this pop up several times and the same rehashed arguments
are given. Counter example to your claims:
1- Library should throw on every pre-condition violation. Sometimes
this is overly expensive or impractical to calculate. My favorite
Re: Does a function know where it was called from?
It creates very fragile code if it acts differently depending on who
called it. The only contexts I can think of that this information would
be truly useful is: Logging (Java, for instance, provides stack-traces
on exception), and sandbox security (is this codebase allowed call me?).
Perhaps you can explain your actual goal.
called it. The only contexts I can think of that this information would
be truly useful is: Logging (Java, for instance, provides stack-traces
on exception), and sandbox security (is this codebase allowed call me?).
Perhaps you can explain your actual goal.
Re: Does a function know where it was called from?
Victor is correct. But there are ways (which are not standard) where
you can print out a stack trace to get this information. It comes in
handy when you can't get a core file and need some information on what
caused a crash.
With gcc on Linux there are specific function calls that will let you
do this. Should be similar functions on other platforms/compilers.
you can print out a stack trace to get this information. It comes in
handy when you can't get a core file and need some information on what
caused a crash.
With gcc on Linux there are specific function calls that will let you
do this. Should be similar functions on other platforms/compilers.
Re: simple boost::test, undefined reference to main
...........
Jeff, I tried to subscribe to boost-users list today also by filling
out this page:
[link]
but I have not received any mail from the system.
I had tried joining this list almost an year back also but in vain.
Hence I post to this group.
do you have any suggestions?
Jeff, I tried to subscribe to boost-users list today also by filling
out this page:
[link]
but I have not received any mail from the system.
I had tried joining this list almost an year back also but in vain.
Hence I post to this group.
do you have any suggestions?
Re: simple boost::test, undefined reference to main
..............
Thanks a lot. I had to pass -static option to g++ for it to work. This
is what I missed.
thanks again
suresh
Thanks a lot. I had to pass -static option to g++ for it to work. This
is what I missed.
thanks again
suresh
Re: c++ programmers' salaries
There are sites on the internet which give you averages and ranges for
particular jobs in particular areas.
[link]
Note, that in the US, it varies significantly by location, but is
usually somewhat proportional to cost of living in that location.
particular jobs in particular areas.
[link]
Note, that in the US, it varies significantly by location, but is
usually somewhat proportional to cost of living in that location.
Re: iterators in sets - should they be const?
Well, your code was always broken C++. With the new conformance, the
compiler now tells you its broken C++.
Technically it's more than that. The standard requires it to be a
strict weak ordering (irreflexive, asymmetric, transitive, and the
resulting equality relation is transitive), but I think you get the
compiler now tells you its broken C++.
Technically it's more than that. The standard requires it to be a
strict weak ordering (irreflexive, asymmetric, transitive, and the
resulting equality relation is transitive), but I think you get the
Re: optimizing the integer rescaling
Depending on the size of the image, you can try generating a lookup
table. You can use something like Bresenham's Line Algorithm to build
that table using only integers.
comp.programming is a better place, or comp.graphics.algorithms.
table. You can use something like Bresenham's Line Algorithm to build
that table using only integers.
comp.programming is a better place, or comp.graphics.algorithms.
Re: iterators in sets - should they be const?
Sorry, misrecalled that. In any case, mutable does the trick.
Re: iterators in sets - should they be const?
It has been a long discussion (10 years :-) about the best solution.
None was really found!
The current position is that making the iterators const protects us
from accidentally modifying the key. Anyone believing that "I know
what I am doing" can use a const_cast to bypass the protection (and
suffer the consequences).
None was really found!
The current position is that making the iterators const protects us
from accidentally modifying the key. Anyone believing that "I know
what I am doing" can use a const_cast to bypass the protection (and
suffer the consequences).
Re: iterators in sets - should they be const?
That requirement is already in C++03 and I suppose in C++98 too.
The following is expected to work regardless of whether you declare the
iterator as const or not, and any attempt to modify a non-mutable data
member of a set key should halt the compilation process.
using namespace std;
struct Mutable {
The following is expected to work regardless of whether you declare the
iterator as const or not, and any attempt to modify a non-mutable data
member of a set key should halt the compilation process.
using namespace std;
struct Mutable {
Re: Does a function know where it was called from?
No, not by any standard means.
V
V
Does a function know where it was called from?
Is there a way in standard C++ for a function to determine where it
was called from? For example.
add(int x, int y)
{
std::cout << "Called by: " << what_function? << std::endl;
return x + y;
So if add() was called directly from main() then main() would be
printed. Or if add() was called by another function, then the name of
was called from? For example.
add(int x, int y)
{
std::cout << "Called by: " << what_function? << std::endl;
return x + y;
So if add() was called directly from main() then main() would be
printed. Or if add() was called by another function, then the name of

