Avoiding Dependencies #1

Avoiding Dependencies #1

Many C++ programmers will be familiar with the tidal wave of recompilations that occur when a seemingly unrelated header file is changed. C++ file dependencies need to be managed otherwise compilation times will grow unchecked. Large build times can cripple the process of creating software and eventually kill a project.

One tip that can help sometimes is to remove the #include and use a template instead. Here’s an example.

Suppose you’ve written a small framework that tokenizes a source file. The representation of a token need not be the obvious string; it could be two iterators that mark the beginning and end of the token as it appears in the whole source file, stored somewhere else as a vector of chars:

 #include namespace source_file{    class token    {    public: // types        typedef std::vector container;        typedef typename container::iterator iterator;        ...    public: // 'tors        token(iterator begin, iterator end);        ...    private: // state            const iterator begin, end;    };}


Programmatically, the #include in this fragment is required because the token class stores vector::iterators by value (and even if it didn’t there’s no way to forward declare a nested class, and anyway the ISO C++ standard prohibits you from explicitly forward declaring anything in the standard C++ library). The slight feel of

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several