Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

correctness

When is the use of std::ref necessary?

June 6, 2023 by Tarik

One of the example where std::ref is necessary: void update(int &data) //expects a reference to int { data = 15; } int main() { int data = 10; // This doesn’t compile as the data value is copied when its reference is expected. //std::thread t1(update, data); std::thread t1(update, std::ref(data)); // works t1.join(); return 0; } … Read more

Categories c++ Tags c++, c++11, correctness, portability Leave a comment

Correctness of Sakamoto’s algorithm to find the day of week

March 20, 2023 by Tarik

Well, you can tell just by looking at it that it is correct… Assuming that the t[] array is correct, which you can verify with just 12 spot checks (one for each month using any day/year). The y -= m < 3 is a nice trick. It creates a “virtual year” that starts on March … Read more

Categories c Tags algorithm, c++, correctness, dayofweek Leave a comment

Switch statement with returns — code correctness [closed]

December 31, 2022 by Tarik

Remove the break statements. They aren’t needed and perhaps some compilers will issue “Unreachable code” warnings.

Categories c Tags c++, correctness, switch-statement Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa