|  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11
Is this a valid optimisation?
I've seen one compiler where this: int32_t get_val(char const *s, std::size_t len, uint8_t base) { bool is_neg; // set isneg int32_t min = std::numeric_limits<int32_t>::min(); int32_t max = std::numeric_limits<int32_t>::max(); int32_t lim = isneg ? (-(min / base)) : (max / base); /... 13 Aug 2010 14:39
Output Generated From Templates
Hi all, Is there any tool or compiler that will output the result of C++ template instantiation? I think such a thing could be useful for advanced template code development, and also education. Cheers, P. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.modera... 12 Aug 2010 15:52
STL implementation of list::sort
I was wondering how is list member function sort implemented in STL. Since list has bidirectional iterator so any of the random access iterator based sorting algorithms (heap sort, quick sort etc) can not be applied on lists. Still the complexity of list::sort is NlogN. So which algorithm does it apply? I tried t... 12 Aug 2010 19:10
Why does a base function hide a function in a derived class?
It is normal that a function in derived class hides one in a base class. But, I could explain to myself how a base function could hide one in a derived class. Here is an example: struct A { int x(); }; struct B : A { }; struct C : A { }; struct D : B, C { using A::x; int x(double); void f();... 13 Aug 2010 01:41
Compile error on templated STL map class
I have a class template (ExclusiveMap) which takes two type parameters C1 and C2 and declares two private members map<C1, C2> and map<C2, C1> (both STL maps). In test code I instantiate this class template providing types int and string for C1 and C2 respectively. The test code compiles cleanly using GCC 3.2 howe... 12 Aug 2010 08:10
copy constructor elision
class A { }; class B : public A { B(const B& other); public: explicit B(){} }; int main() { A const & a = B(); // L1 A a2 = B(); // L2 } Why VC++ 2010 and g++ give error related to private copy constructor in 'B' in Line L2. I understand the Line L1 is governed by $8.5.3/5 ... 13 Aug 2010 14:39
Problem with printing to a file
Hi, I wrote a program in which the main part is a loop with a big number of iterations (the program takes about 1 day to perform the calculations i want) that imitates a flow of time ("professionally speaking": time evolution). After each iteration of the loop I send some data to files. To make the long story shor... 12 Aug 2010 15:52
Digital Mars C/C++ Compiler: test results
> ----------------------------------alignment------------------------------------ On 9 Aug, 01:48, Walter Bright <newshou...(a)digitalmars.com> wrote: Digital Mars C++ is very fast at compiling, far faster than any other C++ compiler. I have tested free Digital Mars C/C++ Compiler v. 8.52 from http://www.dig... 13 Aug 2010 19:03
ADL and C++0X Lambdas
Are there supposed to be some strange interactions with C++0X lambdas and ADL? The following code, works in Intel 11.1 and GCC4.5 but fails in VisualStudio 2010. Is this a Microsoft bug? If so, I posted it on https://connect.microsoft.com/VisualStudio/feedback/details/585643/bug-in-adl-lookup-with-c-0x-lambdas#de... 12 Aug 2010 15:52
Groups down
The groups are experiencing server problems. We expect to be back on line evening of 12 August. Messages in queues will be processed. Mailers will likely deliver other posts shortly after recovery. When we come back, please allow eight hours before reposting any articles which have not been processed. Tha... 11 Aug 2010 23:33
Vptr
Hi! I have another naive question. I have been trying to understand the polymorphysim implementation in C++. I believe that most of the compilers implement it using vptr and vtables. My question is when for every object of a class (which has a virtual member) if vptr points to the same vtable, why does every obj... 12 Aug 2010 12:33
why template version is prefered in this case
#include <iostream> using namespace std; template <typename T> void f(const T a) { cout<<"Template version."<<endl; } void f(const int* a) { cout<<"Plain version."<<endl; } int main() { int *a=0; f(a); return 0; } the output is Plain version., I don't... 12 Aug 2010 19:10
Is there std function that calculates a bounded value?
Is there a boost/std equivalent to: template< typename rc > rc Bounded( rc const& rValue, rc const& rLowest, rc const& rHighest ) { assert( !( rHighest < rLowest ) ); if( rLowest < rValue ) { if( rValue < rHighest ) { return rValue; } else { return rHighest; } } else { re... 12 Aug 2010 02:47
Shallow copy
Hi I am writing a library in C++. In my library I want to implement a feature that if an application programmer instantiates a class object and later does a shallow copy by memcpy or by any other means. During the run time when ever any function of the shallow copy object is called it should print out a message War... 12 Aug 2010 15:52
Set implementation in STL
How are sets generally implemented in STL. I have read they are implemented as BST, are they some kind of balanced BST like Red Black trees? -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] ... 10 Aug 2010 00:28
output?
int& f(){ static int x = 0; x++; return x; } int main(){ int x = 0; f() += 1; f() = f() + 1; cout << f(); } What should be the output of the code shown? VS gives 5 and gcc gives 6. Regards, Dabs. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ co... 12 Aug 2010 13:39
C/C++ query
For a const variable, in general the compiler does'nt allocate memory for that variable in C++. So you cannot reference the variable to initialize any array for its size as: const int a=5; int arr[a];//incorrect The above code is also verified to be incorrect in Bruce Eckel. But to my surprise its running wel... 8 Aug 2010 17:48
 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11