Description:
Technical discussion of the C++ language. (Moderated)
|
|
|
How to create functions with generic/parametrized operators
|
| |
I am trying to do something, which I think is not possible to do in C+ +. This is what I want to accomplish (pseudo code) parameter <op> func() { for i loop for j loop for k loop x[G(i,j,k)] = x[H(i,j,k)] <op> y[I(i,j,k)] end loop end loop end loop ...main() { func<+>() or func<'+'>()... more »
|
|
removing from set - does it have to be so ugly?
|
| |
std::set<Stuff>::iterator current_item( stuff_set.begin() ); while ( current_item != stuff_set.end() ) { if ( is_bad( *item ) ) { std::set<Stuff>::iterator previous_item( --current_item ); stuff_set.erase( ++current_item ); current_item = previous_item; } ++current_item; ...Is this the best way I can structure this? I hate writing code like... more »
|
|
boost multi index - possible?
|
| |
Hi, I have a map of a set of strings and a double. map<set<string>,double> Typical entries are like this: (a1,b1,c1) -> 10 ; (a1,b1,c2)->2.5 (a1,b1,c2)-> 3 Of course if i give full set as the key, i can get the value. But if i want all entries containing say a1, how to do it? Is it possible to do this through boost::multi-index? I am unable to make out by reading... more »
|
|
Const and usage during compile time
|
| |
const int i[] = {10, 12, 18, 20} //The below isn't legal, the text says because the array above being const, it can't be used at compile time, and the error is "error C2057: expected constant expression". It seems (I tried it) it can't be done whether the array above is const or not, the (here float)array... more »
|
|
Using array of function pointers
|
| |
int main(int argc, char **argv) { std::string (* fp[]) (int) = {binary}; std::cout << fp[0] << std::endl << fp[1]; ...This compiles (in visual studio 2008 express) but fails with run-time error. Why? Thanks, Krishna. P.S. This is not a homework question.
|
|
question on function overloading
|
| |
Hi, I have a class A which is the base class. I have class B which is derived class of A. Class A does not have a default constructor(reason it is a class in c+ + library). I am trying to overload a function of class A in class B and it gives me an error saying there is no appropriate default constructor... more »
|
|
Virtual inheritance and typedef
|
| |
Hi, In the book _C++ Templates: The Complete Guide_ (2003), Vandevoorde and Josuttis devote section 16.1 (pages 285-9) to a technique for implementing "Named Template Arguments". The full code is too long to quote, but can be accessed at the book's website: [link],... more »
|
|
shared_ptr declaration in if-statement ?
|
| |
Hi all. // With a pointer I can do: if(MyWhatever* pX = get_whatever()) { ...However, for this to work with a shared pointer (shared_ptr or scoped_ptr from boost) I have to do: if(shared_ptr<MyWhatever> pX = shared_ptr<MyWhatever>(get_wha tever())) { ...This is ugly (and presumably could also add some runtime overhead).... more »
|
|
Arguement against NULLing a pointer after delete?
|
| |
I seem to remember reading through the C++ FAQ Lite and reading an arguement against setting a pointer to NULL after delete. Is there such an arguement or did I imagine the whole thing? Thanks Allan
|
|
Article: On Iteration
|
| |
I wrote an article that may be of interest on InformIt; it got mentioned on reddit.com. Due to the vagaries of posting time and reddit dynamics, the article didn't stay long on reddit's programming page so it got very few views and comments. [link] Please comment here and/or there and vote up if you liked it.... more »
|
|
|