Sobes.tech
Junior — Middle

What C++ language standards have you used in your practice?

sobes.tech AI

Answer from AI

In my practice, I have used the C++11 and C++14 standards, which significantly expanded the language's capabilities compared to previous versions.

The main features I applied include:

  • Automatic type deduction (auto) — simplifies code and improves readability.
  • Lambda expressions — for convenient creation of anonymous functions, especially in STL algorithms.
  • Smart pointers (std::unique_ptr, std::shared_ptr) — for safe memory management and avoiding leaks.
  • Constant expressions (constexpr) — for compile-time calculations.
  • Range-based for loops — for convenient iteration over containers.

Example of using smart pointers and lambda:

#include <memory>
#include <vector>
#include <algorithm>
#include <iostream>

int main() {
    std::vector<std::unique_ptr<int>> numbers;
    numbers.push_back(std::make_unique<int>(10));
    numbers.push_back(std::make_unique<int>(20));

    std::for_each(numbers.begin(), numbers.end(), [](const std::unique_ptr<int>& num) {
        std::cout << *num << std::endl;
    });
    return 0;
}

Using modern standards helps to write safer, more efficient, and maintainable code.