Cpp

From campisano.org
Jump to navigation Jump to search

HowTo

Projects

External Links

Patterns

Factory


pImpl

Notes:

pImpl is to hide the implementation of a single class

Interface allows polymorphism, an interface reference can have one or more implementation, so it hides implementation details

in c++, there are more things (than java/c#)

- Interfaces does not exists really, exists abstract pure class that are (due to pure) polymorphic

- An header file can have more than one code that meets its contract, and it allows to choice between mutiple implementations (example external .dll or .so) but just one at time (can be just one of that in the running application, you can stop, switch dll/so and run again)

About performance, there is an additional function call to use pImpl if use a std pointer, but pImpl needs a 'new' and 'delete' calls, memory must be reserved and destroyed at runtime for every instiation of the class that use pImpl, and it can be a sensible performance loss in certain cases. In the other hand, interface needs to use a vtable to know what the correct implementation to call for every time a virtual method is called, so that can be a sensible perfomance loss in other cases.

UML

Standard Template Library

References

C:

CPP:

NOTE: CPP11 containers can store references instead of pointers with std::reference_wrapper

std::map<std::string, std::reference_wrapper<const Handler>> m_handlers;

Benchmark

C++11

Tutorials

Libraries

External lists of libraries

Search C++ libraries

How to search in Debian packages tags

  • a similar results can be obtained using command line, using the axi-cache (that is more complete than debtags)
apt-get install axi-cache
# sleep sometime to wait the database update
axi-cache search --all devel::library AND \(cpp OR c++ OR cxx\) AND \(portable OR platform\)

How to compare libraries

  • prioritize high portability
  • prioritize high documentation
  • prioritize low dependencies
Example result subset

Wide scope libraries

Apache Portable Runtime Library

WEB

CGI

FastCGI


WEB Frameworks

Visual Interfaces

Gtkmm

Databases

Firebird

Books

Exceptions / Signals

Generic