C++

std::array vs. std::vector

Written by on August 9, 2022 in C++, Programming with 0 Comments
std::array vs. std::vector

One of the common questions when starting to study the container abstractions in C++20 is “Should I use std::array or std::vector?”. The correct answer is “use what is best suited for the current situation”. That is not good enough, obviously. In this short article, I will try to answer this question based on the intrinsic nature […]

Continue Reading

Understanding std::span

Written by on July 27, 2022 in C++, Programming with 0 Comments
Understanding std::span

Introduced in C++20, std::span is a light-weight abstraction that provides a convenient view into a collection of contiguous elements. Note that it is not enough for the elements to be logically contiguous, but they must be contiguous in memory too. Thus, span will work with C-style arrays, C++ vectors and arrays. It will obviously not work with […]

Continue Reading

Book Review – Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code

Written by on July 11, 2022 in Book Review, C++ with 0 Comments
Book Review –  Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code

Title: Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code Authors: J.Guy Davidson, Kate Gregory Publisher:  Pearson Education Year: 2022 My earliest introduction to C++ guidelines was through Scott Meyers’ excellent book Effective C++ that first appeared in 1992. After programming in C++ for around 3 years at that point, the book […]

Continue Reading

C++20 [[no_unique_address]] Attribute

Written by on June 26, 2022 in C++, Programming with 0 Comments
C++20 [[no_unique_address]] Attribute

The [[no_unique_address]] attribute was introduced in C++20 to give a compiler the freedom to optimise memory allocation of a struct/class when it contains a subobject that does not have any members. The other requirement is that the subobject should not be a static member of the enclosing struct/class. Let us start with the basics first. […]

Continue Reading

Using DLL Functions in Rust

Written by on May 4, 2022 in C++, Programming, Rust with 1 Comment
Using DLL Functions in Rust

When you program in Rust, especially in a non-trivial project, there is a good chance that you will need to call “external” functions (usually, C/C++) that are available in a DLL (we are talking about the Windows platform here). It could be because you wish to re-use some code that you have earlier written in […]

Continue Reading

Rust Trait vs. C++ Abstract Class

Written by on April 3, 2022 in C++, Programming, Rust with 0 Comments
Rust Trait vs. C++ Abstract Class

Traits in Rust are an amazing feature and contribute significantly to the expressive power of the language. For someone coming to Rust with a C++ background (like me), Traits appear to be quite similar to Abstract Classes in C++. Although they are similar, Traits have certain characteristics that set them apart. In this article, I […]

Continue Reading

C++ 20: Concepts

Written by on September 19, 2021 in C++, Programming with 0 Comments
C++ 20: Concepts

Concepts, introduced in C++20, are predicates that act as contraints on template parameters. As you would expect, the nice thing is that the constraint checking happens as part of template instantiation at compile time and not at run time! Since templates can have type as well as non-type parameters, Concepts can be applied to both […]

Continue Reading

First Encounter with the Ring Programming Language

Written by on August 7, 2021 in C++, Programming, Ring Language with 0 Comments
First Encounter with the Ring Programming Language

The Ring Programming Language, designed by Mahmoud Fayed,  has been around since 2016. I came to know of it quite accidentally two weeks ago when I received a promotional email from Apress about their book “Beginning Ring Programming” by Mansour Ayouni, published in 2020. I immediately did a google search about the language and finding […]

Continue Reading

Getting to Know Visual Prolog 10

Written by on June 6, 2021 in C++, Programming, Prolog with 0 Comments
Getting to Know Visual Prolog 10

Visual Prolog has its roots in Turbo Prolog, which was popularized by Borland in the mid 1980s. It is developed and supported by PDC A/S, Denmark. So how is Visual Prolog different from other Prolog implementations out there, for example, SWI-Prolog or Sicstus Prolog? Here are the key differences: 1) It is not an ISO Prolog  […]

Continue Reading

C++20 [[nodiscard]] Attribute

Written by on January 17, 2021 in C++, Programming with 0 Comments
C++20 [[nodiscard]] Attribute

[[nodiscard]] attribute “encourages” the compiler to issue a warning when the return value from a function is ignored. It was introduced in C++ 17 and enhanced in C++ 20 to include a string literal that can be used as an explanation of the warning. Let us look at different cases one by one. Case-1: An enumeration […]

Continue Reading

Top