Posts

Principles in C++

  One Definition Rule Rule of three Tagged Constructors    Small object optimization( https://riptutorial.com/cplusplus/example/31654/small-object-optimization) Empty Base Class Optimization Optimizing by executing less code Expression templates Fold Expressions Perfect forwarding Returning several values continuation passing style Function Object Consumer Returning several values from a function Argument Dependent Name Lookup A moved-from optional Constexpr unions Deferred argument evaluation Preconditions Empty list initialization Intuitive interface The inline keyword as ODR guard dismisser noexcept destructors Value-initialization with C++ Too perfect forwarding variadic macros Ref-qualifiers Inadvertent conversions conditional copy constructor String’s interface Efficient optional values Overload resolution Sessions and object lifetimes Competing constructors Toggles in functions Compile-time string concatenation A friendly type predicate Requires-expressio...

C++ Idioms

 http://cplusplus.bordoon.com/cplusplusadvice.html https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Print_Version RTTI Virtual functions shared_ptr etc Templates Virtual inheriting Variadic macros Also useful: Attributes (it depends on your compiler) Variadic templates Variadic functions Constexpr (sorting in compile time / calculating hash of strings etc... but the latter is related to the last section) Lambdas Useful for brainfucking or in special cases: CRTP SFINAE inable_if (type traits) Foreach macro User-defined literals opaque pointer https://akrzemi1.wordpress.com/page/2/ https://www.ritambhara.in/category/cpp/

flags in C++

 gcc -g -lpthread -I <path> -std=c++ 

Event based design pattern

 https://bastian.rieck.me/blog/posts/2015/event_system_cxx11/ https://www.codeproject.com/Articles/6614/Generic-Observer-Pattern-and-Events-in-C

Interview questions

Orion Innovations class A {           public:     A()     {         printf("A def ctor\n");     }     ~A()     {         printf("~A def dector\n");     }     char ac; }; static A statObject; int main() {     printf("Size of A = %d\n", sizeof(A));     printf("main()\n"); } //===================== //output: here // A def ctor Size of A = 1 main() ~A def dector struct A {     A() { cout << "A" << endl; }     ~A() { cout << "~A" << endl; } }; struct B {     B() { cout << "B" << endl; }     ~B() { cout << "~B" << endl; } }; struct D {     D( D& d ) { cout << "&D" << endl; }     D() { cout << "D" <...

ONT(OMCIv1)

 show equipment ont interface 1/1/3/5/1 configure equipment ont interface 1/1/3/5/1 sernum ALCL:F8612E96  voip-allowed enable sw-ver-pland  disabled # admin state up admin state up exit .. 5 times configure vlan id 40 mode residential-bridge new-broadcast enable new-secure-fwd enable in-qos-prof-name name:Default_TC1 configure vlan id 30 mode residential-bridge new-broadcast enable new-secure-fwd enable in-qos-prof-name name:Default_TC1 configure vlan id 30  no vlan id 30 configure qos profiles bandwidth us_prof_voip_2pots_bw committed-info-rate 600 assured-info-rate 600 excessive-info-rate 600 delay-tolerance 8 configure qos interface 1/1/3/5/1/voip upstream-queue [0...7] bandwidth-profile name:us_prof_voip_2pots_bw typ:isadmin># configure qos interface 1/1/3/5/1/voip upstream-queue [0...7] bandwidth-profile name:us_prof_voip_2pots_bw typ:isadmin># configure qos interface 1/1/3/5/1/voip upstream-queue 0 bandwidth-profile name:us_prof_voip_2pots_bw typ:isadmin...

Networking Issues

Data overwriting 'a' value = 'b' value (can occur due to port overlapping)  Port overlapping Mirroring in a network Self port or Self identity or looping Sending message to itself