Noutați

How To Use Alias Templates For Traits In C++ 17 and Beyond

One of the great features of C++ is templates, they are parameterized by alias templates in C++11. Then, In C++14 and C++17, they improved C++11’s feature with a number of template aliases whose use simplifies the traits. This feature is called “Alias Templates For Traits” and in this post, we explain what is and alias template and how we can use alias templates with traits. What is a template In C++ ? A template is a simple and a very powerful statement in C++ which defines the operations of a class or function and lets the user apply the same template on different types in those operations. A template defines the operations of a class, a function, it is an alias. For example, we can create an add(a,b) function template as shown below.   template T add (T a, T b) {   return a+b; }   What is a type alias, and an alias template in C++ 11? Type Alias is a term that refers to a previously defined types, alias declaration can be used to declare a name to use as a synonym for a previously declared type. We use using declaration (using-declaration) to declare a type alias, and it is effectively the same as typedef. This can be in block scope, class scope, or namespace scope. Type alias does not introduce a new type and it cannot change the usage or meaning of an existing type name. A type alias declaration is completely the same as typedef declaration. Type alias can be used to create an alias template that can be used as a custom allocator. Type alias which comes after C++11 standard, is used to create an alias template which can be used as a custom allocator. An alias template is an alias that uses a template which refers to a family of types. For example, let’s create a table template which has type, rows and cols parameters. We can create this table (my_table) template as below,   // A Template Example template class my_table { };   We can use this template to create two more alias templates. Here we create a single column (my_column) and a single row (my_row) templates as below,   // Alias Template Example template using my_column = my_table; template using my_row = my_table;   As you see, we have a my_table template and my_column, my_row templates which are alias templates of the my_table template. These templates can be used to with any data types (int, float, char, string, wstring, etc.). Now we can use all the templates to create a table which has rows and columns or a single row or a single column data in a given type. Here is how we can use them,      my_table  table1;    my_column col1;    my_row row1;   What are the alias templates for traits in C++ 14? In C++17, there are alias templates for type traits, they are defined in header and they can be used by using #include . In C++17, they improved C++11’s TransformationTraits feature with a number of template aliases whose use simplifies the traits. According to N3655 paper, “A TransformationTrait modifies a property of a type. It shall be a class template that takes one template-type argument and, optionally, additional arguments that help define the modification. It shall define a nested type1 named type, which shall be a synonym for the modified type.” In […]

Read More

All Your IT Team Wants This Holiday Season is a Break!

The holiday season is all about giving. As organizations increasingly look to IT as they move toward new digital tools and processes, now is the perfect time to give back to IT teams tirelessly working to keep the modern enterprise online. Whether your system performance has been naughty or nice this year, there’s no denying that tech professionals have earned our appreciation, respect—and the tools to set them up for success in 2024. For IT teams limited in both time and resources, simply maintaining systems can feel as impossible as squeezing themselves down a chimney or delivering gifts to millions of homes in a single night. On top of that, instead of being greeted with milk and cookies, they’re inundated with endless performance issues, support requests and alerts—leaving little time left over for the important work of innovating. They say the best gifts are the ones you can’t wrap. That holds true for IT teams, too. This year, bring your organization the gift of a simpler, speedier, more rewarding workload. If your team is dreaming of a tech-savvy future, here are some enterprise software solutions to make their lives easier that they won’t want to re-gift: Enjoy the View With Observability Everyone loves to cozy up at home during a winter snowstorm, but with the widespread migration to combined remote, on-premises and distributed hybrid environments, the daily monitoring journey for today’s IT teams is more akin to trekking blindly through a blizzard. Observability tools are metaphorical snowshoes and goggles that can help them not only weather the storm but see clearly from the mountaintop. Observability is the answer to the modern enterprise’s struggle to gain full visibility into their organization’s apps, networks, databases and infrastructure—something nearly half of IT professionals lack, according to SolarWinds research. IT teams will be able to rest easier at night with visions of sugarplums, rather than outages or anomalies, dancing in their heads. Even better, integrating artificial intelligence (AI) capabilities into observability solutions to collect and provide data on what’s not performing as expected and why will help your teams take a proactive approach to solving issues. Lend a Helping Hand With AIOps AI isn’t just the shiny new toy of the tech world. Organizations using AI for IT operations (AIOps) can give the gift of support to their overworked IT teams by automating some of the time-consuming and mundane tasks that stand between them and a focus on innovation. Adding AIOps to observability can provide IT teams with maximum visibility into the state of their digital ecosystems through automated discovery and dependency mapping. Additionally, your teams can gain the ability to easily track inbound connections linked across the organization’s application stack and storage volumes with auto-instrumented views. Today, it simply isn’t feasible for humans alone to manage modern IT environments without intelligent automation. Think of AIOps as a workshop of elves operating in the background to ensure workloads and processes are streamlined and moving as efficiently as possible. With AIOps in place to analyze data and streamline workloads and processes, IT teams are relieved of some pressure—and can focus on accelerating your digital transformation rather than just maintaining it. Give the Gift of Time Finally, although you can’t outright give the gift of time to your IT team, you can still arm them with […]

Read More

What Is Std::any In C++ 17 And How We Can Use It?

C++17 standard is amazing with a lot of new features, and one of the interesting features was the new type std::any. std::any is a type-safe container to store a single value of any variable type. In this post, we explain std::any in modern C++. What is std::any in C++ 17 ? The any class (std::any) is a new class defined in the  header in C++17 and it is used for any type definition, it is a safe type container for single values that are copy constructible. The std::any is a container type that is used to store any value in it without worrying about the type safety of the variable. It has been designed based on boost::any from the boost library. It is very useful, when you have a variable, and you want to change its type (int to float) on runtime. Here is the simplified syntax for std::any.   std::any ;   Here is a simple definition example. The std::any is a type-safe container that has properties such as has_value(), type(), type().name(); it has modifiers such as emplace, reset, swap; it has bad_any_cast helper class, and it can be used with other methods such as make_any, any_cast, std::swap. How can we use std::any in C++ 17? Here is a simple example how we can use the std::any with different types in C++17 and beyond.   #include   int main() { std::any a;     a = true; // boolean a = 100;  // integer a = 9.81; // double }   In some definitions, we can use literals to define type of the variable, let’s see example below. Is there a full example about how can we use std::any in C++ 17? Here is a full example about std::any that shows different any definitions. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42   #include #include #include #include #include   using namespace std::literals;   int main() { std::any a; std::cout

Read More

Three Professional C++ Posts That You Should Read

Hello Developers, 2024 is getting closer, and on your desktop or laptop there is a RAD Studio, C++ Builder 12, a modern C++ IDE. Combine these with a hot coffee, these are enough to develop great applications. C++ remains hugely popular and C++17 was another big milestone in the history of C++. It comes with a lot of new features, and today we have 3 posts about them. We have 3 new post picks from LearnCPlusPlus.org that can be used with the new C++ Builder 12. The first post-pick is about the new fold expressions in C++ 17. Another post is about the filesystem library features that come with C++17 and the other post is about the strings in C++, we teach you what is std::basicstring and UnicodeString in Modern C++. We are amazed by the new RAD Studio 12 that we can develop modern computational applications, and there are big improvements and massive changes in C++ Builder 12 as well as in Delphi 12. Here is an extensive video that explains details of some of the many improvements and changes. RAD Studio’s C++ Builder, Delphi, and their free community editions C++ Builder CE, and Delphi CE are powerful tools for modern application development. Where I can I learn C++ and test these examples with a free C++ compiler? If you don’t know anything about C++ or the C++ Builder IDE, don’t worry, we have a lot of great, easy to understand examples on the LearnCPlusPlus.org website and they’re all completely free. Just visit this site and copy and paste any examples there into a new Console, VCL, or FMX project, depending on the type of post. We keep adding more C and C++ posts with sample code. In today’s round-up of recent posts on LearnCPlusPlus.org, we have new articles with very simple examples that can be used with: The free version of C++ Builder 11 CE Community Edition or a professional version of C++ Builder  or free BCC32C C++ Compiler and BCC32X C++ Compiler or the free Dev-C++ Read the FAQ notes on the CE license and then simply fill out the form to download C++ Builder 11 CE. How to use C++ with C++ Builder? C++17 is another big milestone in the history of C++, it comes with a lot of new features. In C++17, the fold expressions feature is a powerful tool that allows us to fold a parameter pack over a binary operator. Folding Expressions are very useful with variadic templates, and this feature makes template arguments more readable and concise. There are 4 different types of usage and in the first post we will give syntax and simple examples about each of them. In modern C++, the filesystem library allows portable interaction with directories and directory-like structures providing functions such as listing directory contents and moving files. After the C++17 standard, the contents of the Filesystems Technical Specification are now part of modern C++ and are implemented in the filesystem library. Some of classes are path, directory_entry, directory_iterator, perms, file_status, … and some of non-member functions in this library are copy, copy_file, current_path, exists, file_size, rename, remove, status, is_directory, is_empty, … In the last post we explain what is the Filesystem Library in modern C++ and we have very educational examples. In programming, one of the most used variable types are text strings, and they are sometimes really important when storing and retrieving valuable data. It is important to store your data safely in its language and localization. Most programming languages have issues when storing […]

Read More

Senser Extends AIOps Reach to Manage SLOs and SLAs

Senser is extending the reach of its artificial intelligence for IT operations (AIOps) platform to now include an ability to define and maintain service level agreements (SLAs) and service level objectives (SLOs). SLOs are a set of internal performance goals that require access to telemetry data from service level indicators (SLIs), while an SLA is a formal commitment to maintaining specific levels of service. Senser CEO Amir Krayden said the company’s AIOps platform collects data from SLIs and then applies predictive AI models to enable IT teams to achieve SLOs and SLAs. The Senser AIOps platform leverages extended Berkeley Packet Filter (eBPF) and graph technology to gain visibility into the entire IT environment versus requiring IT teams to deploy agent software. Machine learning algorithms are then used to aggregate and analyze that data to define thresholds for predicting performance in addition to recommending benchmarks for tracking SLOs and SLAs. That approach provides a single source of truth for identifying the actual level of service being provided based on a topology of the infrastructure, network, applications and application programming interfaces (APIs) that makes it possible to identify the root cause of issues and the potential impact of an outage for degradation of performance. IT teams have been attempting to achieve and maintain SLAs and SLOs for decades, but given all the dependencies that exist in a distributed computing environment, it’s difficult to achieve that goal. Senser is making a case for applying AI within the context of a platform for automating the management of IT to define and maintain SLOs and SLAs to make it possible to consistently manage SLAs and SLOs in a way that reduces the level of cognitive load that would otherwise be required. Senser is also working toward adding generative AI capabilities to provide summaries that explain what IT events have occurred. Collectively, the goal is to provide IT teams with a more efficient holistic approach to monitoring and observability that legacy platforms are not going to be able to achieve and maintain, said Krayden. At the core of that capability is eBPF, a technology that allows software to run within a sandbox in the Linux microkernel. That capability enables networking, storage and observability software to scale at much higher levels of throughput because they are no longer running in user space. That’s especially critical for any application that needs to dynamically process massive amounts of data in near-real-time. As the number of organizations running the latest versions of Linux continues to increase, more hands-on experience with eBPF will be gained. IT teams may not need to concern themselves with what is occurring in the microkernel of the operating systems, but they do need to understand how eBPF ultimately reduces the total cost of running IT at scale. Ultimately, the goal is to reduce the current level of complexity that today makes effectively managing highly distributed computing environments all but impossible for IT teams to manually maintain in an era where the pace at which applications are being built and deployed only continues to accelerate.

Read More

What Are The New Fold Expressions In C++ 17

C++17 is another big milestone in the history of C++, it comes with a lot of new features. In C++17, the fold expressions feature is a powerful feature that allows us to fold a parameter pack over a binary operator. Folding Expressions are very useful with variadic templates, and this feature makes template arguments more readable and concise. There are 4 different types of usage and in this post we will give syntax and simple examples about each of them. What are the fold expressions that comes in C++ 17 features? The fold expressions are established after the C++17 standard, they are used to fold (reduce) a parameter pack (fold_pack) over a binary operator (fold_op). The opening and closing parentheses are required in a fold expression. In a folding expression there are 4 parameters, fold_pack is an expression that has parameter pack and no operator fold_op is a binary operator, one of the + – * / % ^ & | ~ = < > > += -= *= /= %= ^= &= |= = == != = && || , .* ->* operators fold_init is an initial expression at the beginning or at the end … is an ellipses symbol that used for arguments There are 4 different syntax in usage, now let’s see them in examples, Is there a simple example about unary right fold expression? Unary right fold expression syntax (since C++17),   ( fold_pack fold_op … )   here is an unary right fold expression example,   template bool URF(Args … args) { return (args && …);  // Unary Right Fold }   Is there a simple example about unary left fold expression? Unary left fold expression syntax (since C++17).   ( … fold_op fold_pack )   here is an unary left fold expression example,   template bool ULF(Args … args) { return (… && args); // Unary Left Fold }   Is there a simple example about binary right fold expression? Binary right fold expression syntax (since C++17).   ( fold_pack fold_op … fold_op fold_init )   here is a binary right fold expression example,   template int BRF(Args&&… args) { return (args + … + 100); // Binary right fold addition }   Is there a simple example about binary left fold expression? Binary left fold expression syntax (since C++17).   ( fold_init fold_op … fold_op fold_pack )   here is a binary left fold expression example,   template int BLF(Args&&… args) { return (1 * … * args); // Binary left fold multiplication }   Is there a full example about fold expressions in C++ 17? Here is a full example about fold expressions in C++17 that has 4 different types in usage. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41   #include   template bool URF(Args … args) { return (args && …);  // Unary Right Fold }   template bool ULF(Args … args) { return (… && args); // Unary Left Fold }   template int BRF(Args&&… args) { return (args + …+ 100); // Binary Right Fold Addition }   template int BLF(Args&&… args) { return (1 *…* args); // Binary left Fold Multiplication […]

Read More

Directly Edit Unreal Engine Projects in Visual Studio 2022

Directly Edit Unreal Engine Projects in Visual Studio 2022 David Li December 12th, 20230 1 Introduction We are excited to announce that Visual Studio 2022 version 17.9 Preview 2 offers direct support for Unreal Engine projects. We would like to give a special thank you to the folks at Epic Games. Our on-going collaboration made this feature possible. In addition, this feature relies on the latest features of Unreal Engine 5.4. You will no longer need to generate a Visual Studio solution. Currently, whenever you are working with Unreal Engine projects in Visual Studio, you must generate a Visual Studio solution from within the Unreal Editor or using the Unreal Build Tool (UBT). However, this process can become cumbersome whenever a new asset is added from within the Unreal Editor, or by another team member. In those cases, the Visual Studio solution must be regenerated to reflect these changes. With the direct support of the Unreal Engine project format (.uproject) in Visual Studio, you can now seamlessly switch between Visual Studio and the Unreal Engine editor. All your changes will be automatically synced. First, our goal is to provide you with an experience that is on par with using the generated Visual Studio solutions without compromises. You will have access to the same rich IntelliSense and debugging capabilities that you are used to. Moreover, all the Unreal Engine-specific features that we have added to Visual Studio will work seamlessly when using Unreal Engine projects directly. For the time being, opening an Unreal Engine project directly requires the use of a source build of Unreal Engine. Additionally, we plan to extend support to older versions of Unreal Engine as well in the future. Finally, we are actively seeking feedback from all of you to improve this feature. Getting Started with Directly Editing Unreal Engine Projects You will need to install Visual Studio 2022 version 17.9 Preview 2 and select the “Game development with C++” workload to start previewing this feature. Make sure to also select the optional component “Unreal Engine uproject support (Preview)” as the component is required for this feature. As previously mentioned, please note that this preview version requires working with a source build of Unreal Engine 5.4. To preview direct support for .uproject in Visual Studio 2022, we will use the Lyra sample game. To obtain the sample working with Unreal Engine 5.4 sources, follow these steps: Follow Epic Games’ instructions for accessing Unreal Engine source code before starting. Ensure that you are using the Unreal Engine 5.4 source code on the ue5-main branch. As the Unreal Engine code base is very large, we recommend not cloning the full history. Instead, use the following command to clone the branch: git clone –branch ue5-main –depth 1 https://github.com/EpicGames/UnrealEngine.git After cloning, run the setup script to get the prerequisites. From the Unreal Engine source root, run: .Setup.bat In the source root, edit the file cpp.hint to remove the lines that define UCLASS, UPROPERTY, and UFUNCTION. Removal of these lines will enable Visual Studio’s support for those features. (Optional) We highly advice installing the Visual Studio extension for Unreal Engine to enable Blueprints integration. For a source build, follow our instructions. In short, from your Unreal Engine source root, navigate to EnginePlugins and run: git clone https://github.com/microsoft/vc-ue-extensions.git You are now ready to […]

Read More

This Is How To Use C++ Functions In A Python App

Do you want to know how to create and C++ functions in a Python app? In this article we will show you how to use the new C++ Builder 12 to create a C++ function, step by step, and then call that function in any Python app. C++ Builder 12 is released packed full of great features, optimizations, and improvements. One of the great features of C++ Builder 12 was the inclusion of an initial CLANG C++ compiler which is another big step introducing a new 64bit bcc64x CLANG compiler which supports C++11, C++14, C++17, and partially C++20 standards. It is still in active development, but I would like to explain there is a great feature of new clang compiler that supports the latest Python modules. In this post, we explain how to develop Python modules with the new bcc64x C++ Builder 12 CLANG compiler. Table of Contents What about using Python with Delphi? What is Python? What is the new C++ Builder 12 and its new CLANG Compiler? How to write a Python module in C++? How to develop Python modules with the new C++ Builder 12 CLANG compiler? Step 1. Generate Python import library Step 2. Copy Python import library Step 3. Create your C++ code for the Python module Step 4. Create some Python code that uses the module Step 5. Create a bat file that creates a shared library using bcc64x Step 6. Execute compile.bat and run Python example What about using Python with Delphi? If you are using Delphi, you should also check out the Python4Delphi tools. You can find out more about our free Python tools here. and read about Python4Delphi in this blog post: What is Python? Python is hugely popular and has some really useful libraries. Python is particularly strong in the field of AI and machine learning (ML). If you are C++ developer, you might want your users to be able to analyze data with AI modules or frameworks written in the Python language in your applications. Let’s imagine you want the users to carry out a few button-clicks to do some heavy AI analysis. That way you get the best of both worlds by having the raw speed and power of C++ which can run Python modules. In the programming world today, the Python programming language is very popular – perhaps second only to C++. Python is easy to use, and hugely popular because it is easy to learn and has the support from big companies like Google. One of the areas in which Python is particularly successful are with libraries and frameworks for AI technology and machine learning. It is a great object-oriented, interpreted, and interactive programming language. Python has very clear syntax. It has modules, classes, exceptions, very high-level dynamic data types, and dynamic typing. There are interfaces to many system calls and libraries, as well as to various windowing systems. New built-in Python modules are easily written in C or C++. Python is also usable as a scripting extension for applications written in other languages that benefit from its ease of use. Python is free to use. More information can be found on their official web page https://www.python.org/ The latest version of Python (at the time of writing) is Python 3.12, released in October 2023. It has a lot of new changes […]

Read More

What Is the Future Workforce and How Will it Impact DevOps Teams?

The rapid changes in technology, work patterns and demographics are ushering in a new era for the labor market known as the future workforce. In this context, DevOps teams—tasked with developing and delivering software quickly and efficiently—are facing novel challenges and opportunities.  This article will explore the key characteristics of the future workforce, from remote working to the gig economy, and explores how these changes will impact the roles, practices, and skill sets of DevOps teams. Understanding these dynamics is crucial for both staying competitive and fostering innovation in an ever-evolving professional landscape. What Is the Future Workforce? The future workforce refers to the evolving nature of the labor market, shaped by factors such as rapid technological advancements, demographic shifts, and changes in work patterns and organization. It’s a concept that’s important to understand given its profound implications for businesses, employees, and society at large. The future workforce is already here, and it’s changing the way we work. With every passing day, traditional work models are being challenged and redefined, leading to a professional landscape that’s increasingly diverse and dynamic. By exploring the future workforce, you’re not just preparing for changes that may affect your career or business. You’re also discovering opportunities for growth and innovation. Whether you’re an employee looking to future-proof your career, a business owner seeking to attract and retain top talent, or a policymaker aiming to foster economic development, understanding the future workforce is crucial. The Composition of the Future Workforce Remote Workers One of the most significant shifts in the future workforce is the rise of remote workers. As technology continues to evolve, more and more people are choosing to work from home or any location of their choice. This trend is driven by many factors, including the desire for a better work-life balance, the need to save time and money on commuting, and the opportunity to work in a more comfortable and personalized environment. Remote working isn’t just good for employees; it’s also beneficial for businesses. Companies that embrace remote work can tap into a global talent pool, reduce overhead costs and increase productivity.  However, managing a remote workforce requires a different set of skills and strategies. For instance, businesses must invest in technology to facilitate communication and collaboration, establish clear expectations and performance metrics and foster a culture of trust and accountability. Gig Economy Another key feature of the future workforce is the gig economy, characterized by temporary, flexible jobs often facilitated by digital platforms. The gig economy includes a wide range of work arrangements, from freelance work and contract-based projects to short-term jobs and on-demand services. In the gig economy, you’re not tied to a single employer or a rigid work schedule, giving you greater flexibility and control over your work. The gig economy offers many benefits, such as the ability to earn additional income, the flexibility to work when and where you want, and the opportunity to pursue a variety of work experiences. However, it also comes with challenges. Gig workers often face job insecurity, lack of benefits, and financial instability. Therefore, navigating the gig economy requires careful planning and management. Diverse Demographics The future workforce is also marked by increasing diversity. This includes not just racial and ethnic diversity but also diversity in terms of age, sexual orientation, disability status […]

Read More

What Are The New Algorithms That Come With C++ 17?

The C++17 standard came with a lot of new features and improvements. One of the features was the math.h library which modernized math operations with the cmath library. The Parallelism Technical Specification adds several new algorithms to the standard C++ library that we can use in C++ Builder 12. These are modernized in the header in the standard library. In this post, we explain the new algorithms that come with C++17. What Are The New Algorithms That Come With C++ 17? C++17 is mostly focused on efficient parallel execution. The new algorithms which support that are available in the usual simple form as well: for_each_n, sample, search, reduce, transform_reduce, exclusive_scan, inclusive_scan, transform_exclusive_scan, transform_inclusive_scan. Now, let’s see some of examples these new algorithms. Iterating ( std::for_each_n ) In C++ 14, we had for_each() to process each element in a given range. In C++17, there is a new std::for_each_n algorithm that executes a function object for each element in the range.    std::for_each_n( first_elemnt, number_of_elements, function)     std::vector vec {47, 12, 3, 9, 5, 21};   for_each_n( vec.begin(), 3,            [](const auto& param)            { std::cout

Read More