Tag: C++

LiteDB: A NoSQL Database for .NET

Written by on February 14, 2021 in Programming with 0 Comments
LiteDB: A NoSQL Database for .NET

I have been looking around for a compact embedded NoSQL database library for .NET, to use as the back-end of my “iLexicon” system. “iLexicon” is written in Lisp and Prolog (I have written a few articles on it before). At present, the entire dictionary component (containing over 300,000 word entries) is resident in memory, and the […]

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

std::is_standard_layout<>

Written by on June 21, 2020 in C++, Programming with 0 Comments
std::is_standard_layout<>

In our last post, we learnt about the type trait std::is_trivial<T>. Today, let us go through another type trait that is quite similar. The expression is_standard_layout<T>::value returns true if the layout of objects of type T is compiler independent, and hence is of standard format. Else, it returns false. This is important if we create objects […]

Continue Reading

std::is_trivial<>

Written by on June 6, 2020 in C++, Programming with 0 Comments
std::is_trivial<>

Today let us try to understand the type trait std::is_trivial<T>. This trait checks if the given type is a trivial type. For a precise definition of what trivial means, please visit the official page. As usual, we will go through three cases: – Primitive types – Classes without inheritance – Classes involving inheritance Case-1: Primitive […]

Continue Reading

std::is_convertible<>

Written by on May 24, 2020 in C++, Programming with 0 Comments
std::is_convertible<>

The type trait is_convertible<From, To> checks if an object of type From can be “implicitly” converted to an object of type To. The expression is_convertible<From, To>::value returns true if implicit conversion is possible, else it returns false. For more details, please check out the reference. Let us look at three primary cases. Case-1: Pre-defined Types […]

Continue Reading

dynamic_cast<> vs. std::is_base_of<>

Written by on May 9, 2020 in C++, Programming with 0 Comments
dynamic_cast<> vs. std::is_base_of<>

In the last article, we looked at the std:is_base_of<T1, T2> type trait. One question that a reader asked since that article appeared is “How does is_base_of<> differ from the dynamic_cast<> operator?” Good question! In today’s post let me try to address the key differences between the two. I am not going to cover the dynamic_cast<> […]

Continue Reading

std::is_base_of<>

Written by on April 26, 2020 in C++, Programming with 0 Comments
std::is_base_of<>

In our on-going series on C++ Type Traits, today’s topic is about the trait std::is_base_of<>. For the official description, see this. std::is_base_of<A, B>::value takes two arguments, both classes (or structs), and returns true if A is a base class of B and false otherwise. Trivially, std::<A, A>::value is true. Let us look at an example […]

Continue Reading

std::common_type<> Type Trait

Written by on April 12, 2020 in C++, Programming with 0 Comments
std::common_type<> Type Trait

In today’s post, I would like to go over the type trait std::common_type<>. This trait was introduced in C++11. As per the specification, std::common_type<T1, T2, …Tn>::type refers to a type Tx in the given list, which the rest of the types in the list can be implicitly converted to. This works with built-in as well […]

Continue Reading

std::is_empty

Written by on March 28, 2020 in C++, Programming with 0 Comments
std::is_empty<T>

In the previous post, we looked at the std::is_destructible<T> type trait. Today, let us try to understand another type trait std::is_empty<T>. As per the specification, is_empty<T>::value will return true in the following cases: – The class/struct has no non-static data member – The class/struct does not define a virtual function – The class/struct does not […]

Continue Reading

std::is_destructible

Written by on March 15, 2020 in C++, Programming with 0 Comments
std::is_destructible

In the last article, I explained the deleted destructor in some detail. Today, I would like to talk about a related construct, a type trait called std::is_destructible. Type traits, defined in the header <type_traits>, are a big help when it comes to implementing template metaprogramming.  See this article for a nice introduction to type traits in […]

Continue Reading

Top