std::set constructor taking a sorted sequence


In the C++ standard page 472 it says that you can construct a std::set in linear time if the constructor gets a sorted sequence of elements. But how is this possible when insert takes logarithmic time Should the time not ...
Posted On: Monday 26th of November 2012 12:48:29 AM Total Views:  353
View Complete with Replies

RELATED TOPICS OF C Language PROGRAMMING LANGUAGE




implicit constructor

Hi Everyone, I know that implicit conversion is invoked for the following case, class A { public: A(int n) { ... } }; A obj = 2; But is any temp objects created Is the 2 used to create a ...
VIEWS ON THIS POST

215

Posted on:

Sunday 11th November 2012
View Replies!

Template default constructor possible?

I've never had cause to try this before, but is it possible to have a template default constructor I wish to pass the type of a singleton to a class and use the static methods of that singleton object in ...
VIEWS ON THIS POST

202

Posted on:

Sunday 11th November 2012
View Replies!

ambiguous constructor? Is it right?

Dear all, I have the following problem, that I'll try to explain with a very minimal example: class A { }; class B { public: B() { } B(const A&) { } B(const B&) { } }; class C { ...
VIEWS ON THIS POST

107

Posted on:

Sunday 11th November 2012
View Replies!

overloaded assignment operator and copy constructor.

Hi Everyone, I was just wondering, about the overloaded assignment operator for user defined objects. It is used to make sure that the following works properly, obj1 = obj; so the overloaded operator function performs the necessary copy of obj's ...
VIEWS ON THIS POST

164

Posted on:

Sunday 11th November 2012
View Replies!

dynamic array and constructors

I have some old code I've written several years ago that doesn't compile with newer versions of GCC. The code allocates an array of objects that need to be initialized by calling a constructor with one argument: class B; class ...
VIEWS ON THIS POST

74

Posted on:

Saturday 24th November 2012
View Replies!

Do I pass an int by value or reference in constructor?

I have a very simple class for storing two-dimensional coordinates: class Point { public: Point(); Point(const Point &); Point &operator(const Point &); int x; int y; }; If I want a constructor that takes two ints, is it better to ...
VIEWS ON THIS POST

87

Posted on:

Sunday 25th November 2012
View Replies!

Calling virtual method within the constructor

all. I have this class with a virtual method and a constructor that calls this virtual method. A derived class overrides this virtual method, so I expected that when the base's constructor is called, it would call the derived ...
VIEWS ON THIS POST

250

Posted on:

Sunday 25th November 2012
View Replies!

Template constructors of template classes

I have a template: template class MyTemplate { public: template MyTemplate() { bar::something(foo); } } How would I instantiate a local instance of this class MyTemplate () doesn't seem to work. Nor does any other ...
VIEWS ON THIS POST

111

Posted on:

Sunday 25th November 2012
View Replies!

virtual constructors

why virtual destructors are possible but virtual constructors are not...
VIEWS ON THIS POST

122

Posted on:

Sunday 25th November 2012
View Replies!

exception in the constructor invoked by "new" operation

If an exception is thrown, will the memory allocated in the heap be released And what's the underlying mechanism
VIEWS ON THIS POST

144

Posted on:

Sunday 25th November 2012
View Replies!

Passing variable parameters to base constructor.

If I have a base class with a constructor that takes '...' parameters, and I want to derive a class from that and give it a similar constructor and have it pass the variable parameters to the base, is there ...
VIEWS ON THIS POST

80

Posted on:

Sunday 25th November 2012
View Replies!

Re: try block in constructor initialization

On 11 Dez., 07:23, AlfC wrote: > BTW, if A is the only access to H1/H2, I > am not sure whether to make class A a friend of H1 and H2. Is this a > good idea It ...
VIEWS ON THIS POST

79

Posted on:

Sunday 25th November 2012
View Replies!

explicit call of constructor and destructor

Hi Everyone, I have the following code and i'm able to invoke the destructor explicitly but not the constructor. and i get a compile time error when i invoke the constructor, why is this so class Trial { public: Trial() ...
VIEWS ON THIS POST

118

Posted on:

Sunday 25th November 2012
View Replies!

Can exceptions thrown by constructors of global/static variablesbe caught?

The subject line says it. What workarounds are there Is there any motion for supporting it in a future version of the standard Maybe with function try blocks in main() Or are there good reasons why it should not be ...
VIEWS ON THIS POST

114

Posted on:

Sunday 25th November 2012
View Replies!

inline constructor and destructor

, I am confused about when I should use inline constructors and destructors. I have test some simple cases, seems the inline ones are faster. Why some book suggest not use/overuse the inline constructors and destructors
VIEWS ON THIS POST

140

Posted on:

Sunday 25th November 2012
View Replies!

Templated constructor behaviour

I have the following code: #include int foo() { std::cout << __func__ << std::endl; } struct func { void operator()() { std::cout << __func__ << std::endl; } }; class run { private: public: run() { std::cout << "THIS ...
VIEWS ON THIS POST

79

Posted on:

Sunday 25th November 2012
View Replies!

Re-usable singleton class that can construct pointers to objects with non-trivial constructors

As the topic says, I wanted to make a re-usable singleton class that could create pointers to objects with non-trivial constructors. I came up with this: #ifndef SINGLETON_HPP #define SINGLETON_HPP template struct DefaultCreatorFunctor { T * operator()() const { ...
VIEWS ON THIS POST

228

Posted on:

Sunday 25th November 2012
View Replies!

How to implement the virtual constructor behavour in C++

I know that in C++, there is no virtual constructor. But is there any way to implement it by using the virtual function For example: We have a base class Shape, its constructor holds a string to indicate what ...
VIEWS ON THIS POST

86

Posted on:

Monday 26th November 2012
View Replies!

copy constructor elision

I was going through some of the documents to C++0x and noticed a lot of references to copy constructor elision, which supposedly already exists in c++. I'm blanking on what this refers to, and google isn't turning up anything. ...
VIEWS ON THIS POST

156

Posted on:

Monday 26th November 2012
View Replies!

explicit copy constructor

, I noticed the following in the "C++ Coding Standards" book. Why should the code on line 30 be in error Transmogrify accepts a (B obj), and we are passing it a B obj. I understand why the other call ...
VIEWS ON THIS POST

352

Posted on:

Monday 26th November 2012
View Replies!