====================
== William's site ==
====================

Templates and Concepts

I have played around with templates and concepts according to Nicolai Josuttis’s video on templates

image

It is a small exercise, but it is a good example of how to apply different concepts(an English word, means ideas) in C++. In this case, templates and concepts (as a feature introduced in C++20).

Coding Standards

There are different C++ coding standards.

MISRA seems has a very big say in the C++ coding style. MISA stands for Motor Industry Software Reliability Association. It produces guidelines for writing software for cars.

Another one is High Integrity C++. It is developed by a private company called Perforce Software.

I learned about these C++ guide lines when I watched the video about the C++ Core guidelines by Rainer Grimm. Other than the guideline, another thing I learned is that pointer is broken by design.

Read more...

C++ in trading systems

In Trading at light speed: designing low latency systems in C++, David Gross first defines what low latency means. The trigger to target latency is 20-40ns. In order to achieve such low latency, the software is running on FPGA. Then he moved the discussion to data.

Data model accounted for a substantial amount of time in his presentation. One key idea is that, if the data model is not designed with performance in mind, it will slow down the system. The size and locality of the data are two important attributes that need to be taken care of. The data model is called instrument store. It is a core element of his algo (algorithm?). The size is less than 1 kb.

Read more...

Embeded SQLite in my little C++ program

Embedding the enitre SQLite into C++ program is easier than I think. I have basically followed the demo code of RobertoChapa.

I put everything under the subdirectory db. Then I created a subdirectory sqlite for SQLite. In sqlite, it contains the amalgamated zip file of the source code, the amalgamated source code sqlite3.c, the header file sqlite3.h. These are the two main files to interface with the entire SQLite.

This is my directory tree:

Read more...

the majestic brown trout

The trout teaches me about data streaming which is an interesting topic. This is another brief introduction.

There are more interesting things other than networking. Ho Ho Ho.

Fixing the bug of C++

So probably this is an illustration of what it means by “fixing the bug in C++”?

This does not compile in C++11 yet perfectly fine in C++14:

constexpr int get_value ()
{
	int val = 5;
	int val2 = 3;
	return val * val2;
}

Based on C++ Weekly - Ep 178 - The Important Parts of C++14 In 9 Minutes(7m22s)

A list of C++ topics

In Jason Turner’s C++ Weekly Ep 348, he listed out an extensive C++ topics. Understanding these topics makes equips you with expert level C++ knowledge. BUT DOES NOT make you in C++ (programming). The entire video is about building a lambda function, from simple to complex, and different versions.

Here is list of topics:

  1. lambdas (C++11)
  2. struct (C++98)
  3. constexpr (C++11)
  4. operator overloading (C++98)
  5. call operator (C++98)
  6. const member functions (C++98)
  7. braced initialization (C++11)
  8. auto return type deduction (C++14)
  9. “compiler magic” at 3:33 he says “because inside our the call operator overload we cannot see the *this pointer of the lambda”
  10. function parameters (C++98)
  11. pass-by-value (C++98)
  12. attributes on parameters (C++11) e.g. [[maybe_unsed]]
  13. pass-by-reference (C++98)
  14. pass-by-value vs pass-by-reference (C++98)
  15. pre-increment vs post-increment
  16. trailing return types (C++11)
  17. class vs struct (C++98)
  18. private vs public (C++98)
  19. implicit conversions (C++98)
  20. function pointers (C++98)
  21. static member functions (C++98)
  22. using aliases (C++11)
  23. efficiency when chaining functions, 6:35 generic lambdas (C++14)
  24. templates (C++98)
  25. template argument type deduction (C++98)
  26. aias templates (C++11)
  27. template instantiations (C++98)
  28. noexcept (C++11)
  29. noexcept in the type system (C++17)
  30. variadic templates (C++11)
  31. variadic lambdas (C++14)
  32. fold expressions (C++17)
  33. function attributes (C++11)
  34. concepts (C++20) 8:47 to constrain the lambdas
  35. non-type template parameters (C++98)
  36. integer sequences (C++11)
  37. template parameter pattern matching (C++98)
  38. explicit lambda templates (C++17)
  39. tuples (C++11)
  40. unpacking of tuples (C++11)
  41. variadic sizeof...() operator (C++11)
  42. direct-initialization of members (C++11)
  43. mutable keyword (C++98)
  44. non-const member functions (C++98)
  45. reference members (C++98)
  46. member copies (C++98)
  47. object layout (C++98)
  48. member padding (C++98)
  49. order of construction/destruction (C++98)
  50. generalized lambda capture (C++14)
  51. immediately invoked lambdas (C++11)
  52. return value optimization (C++98)
  53. guaranteed return value optimization (C++17)
  54. initializer_list (C++11)
  55. recursive lambda (C++23)
  56. deducing this (C++23)
  57. recursive functions
  58. trivially copyable types (C++98)
  59. higher order functions
  60. dangling references
  61. undefined behavior 16:10 overloaded lambdas
  62. inheritance (C++98)
  63. multiple inheritance (C++98)
  64. function hiding (C++98)
  65. variadic using declarations (C++17)
  66. scoping / lookup rules (C++98)
  67. class template argument deduction (C++17/C++20)
  68. deduction guides (C++17)
  69. algorithms (C++11)
  70. ranges (C++20)
  71. <functional> (C++11)
  72. virtual member functions (C++98)
  73. member function pointers (C++98)
  74. special member functions (C++98/11)
  75. member function call syntax (C++98)
  76. type erasure (C++98)
  77. dynamic vs automatic storage (C++98)
  78. Missing
  79. writing your own concepts?
  80. type traits?
  81. operator <=>?
  82. protected?
  83. virtual inheritance
  84. compilation model
  85. ODR violations
  86. preprocessor
  87. project structure and layout
  88. the breadth of the standard library
  89. variable templates
  90. coroutines
  91. modules

From the comments of an user @darkmagic543, there are additional topics:

Read more...

Some interesting BGP information

After watching Petr’s video on deploying BGP in the data center, after some googling, I have summarized some interesting configuration and use case about BGP.

  1. BGP fast fallover That is, kill the BGP session immediately when the link is down. Suitable for peering over point to point links.

  2. Multipath relax It is about traffic load-balancing. This feature is required for ECMP (equal cost multipath).

  3. Allowas-in This feature accepts different eBGP updates with the same AS.

    Read more...

Building Scalable Data Centers: BGP is the Better IGP

In the video Building Scalable Data Centers: BGP is the Better IGP, Petr Lapukhov tells us why BGP is chosen.

Firstly, he states the situation as the problem statement:

  • many servers with 1G/10G NICs
  • traffic is East-West as well as North-South

The objective:

  • simple physical topology
  • simple routing protocol
  • well supported by vendors

The justification of choosing BGP is given:

  • better vendor support
  • simple enough
  • per-hop traffic engineering. (In this context, he means the next hop route can be easily controlled. Not the traffic engineering in the context of RSVP.)
  • easy to troubleshoot
  • the event propagation is more constrained. That is to say, link failure is limited to the two routers of the link. In the case of OSPF, all the routers need to do SPF calculations.
  • the information is straight forward, just the various RIB’s. For OSPF, the link state database needs to be consulted.

Down sides

Read more...

The comma operator (almost made me have a coma to understand it.)

I tried to understand the comma operator. I have tried the following small program:

#include <iostream>

int main ()
{

	int j = 0;
	int k = 0;
	j = 4,5;
	k = (4,5);

	std::cout << "j: " << j << std::endl;
	std::cout << "k: " << k << std::endl;

	return 0;
}

The compiler does give some warnings, despite a little bit different:

 warning: expression result unused [-Wunused-value]
    8 |         j = 4,5;
      |               ^

 warning: left operand of comma operator has no effect [-Wunused-value]
    9 |         k = (4,5);
      |              ^     

and the result is:

Read more...
Previous Page 2 of 5 Next Page