C++C++11C++14C++17C++20Learn C++Syntax

What is the negation (std::negation) metafunction in C++?

What is the negation stdnegation metafunction in C++

Metaprogramming is another great feature of modern C++ that allows programs to redesign themselves during compilation or run time. In C++17, another new feature of metaprogramming is introduced, logical operation metafunctions. These are variadic metafunctions that are conjunction, disjunction, and negation which can be used for metaprogramming features of applications. In this post, we explain what the negation (std::negation) metafunction is.

What are the logical operation metafunctions in C++?

Modern C++ has metaprogramming abilities which is a programming technique that means a program can be compiled to read, create, analyze, or transfer other program code; or it can compile itself. Metaprogramming can change the way code behaves while running.

In C++17, new variadic metafunctions are released for metaprogramming, these are conjunction, conjunction_v, disjunction, disjunction_v, and negation, negation_v. These traits short-circuit in the metaprogramming sense: template specializations that are not required to determine the result are not instantiated.

What is the negation (std::negation) metafunction in C++?

In C++, negation (std::negation) or negation_v (std::negation_v) is a type trait that is defined in the <type_traits> header that is used to design the logical negation between classes (data types, structs, classes). It is a kind of logical template of NOT on a variadic pack of values.

Here is the simple definition of std::conjunction.

Is there a simple example of how to use negation in C++?

Here is a simple example about negation in C++.

Is there a full example of how to use negation in C++?

Here is a full example about negation in C++.

For more new details about std::set, you can check this paper P0013R1

What is the negation stdnegation metafunction in modern C++ C++ logo

C++ Builder is the easiest and fastest C and C++ compiler and IDE for building simple or professional applications on the Windows operating system. It is also easy for beginners to learn with its wide range of samples, tutorials, help files, and LSP support for code. RAD Studio’s C++ Builder version comes with the award-winning VCL framework for high-performance native Windows apps and the powerful FireMonkey (FMX) framework for UIs.

There is a free C++ Builder Community Edition for students, beginners, and startups; it can be downloaded fro

Oh hi there 👋
It’s nice to meet you.

Sign up to receive awesome C++ content in your inbox, every day.

We don’t spam! Read our privacy policy for more info.

About author

Dr. Yilmaz Yoru has 35+ years of coding with more than 30+ programming languages, mostly C++ on Windows, Android, Mac-OS, iOS, Linux, and some other operating systems. He graduated and received his MSc and PhD degrees from the Department of Mechanical Engineering of Eskisehir Osmangazi University. He is the founder and CEO of ESENJA LLC Company. His interests are Programming, Thermodynamics, Fluid Mechanics, Artificial Intelligence, 2D & 3D Designs, and high-end innovations.
Related posts
C++C++17C++20C++23Learn C++Syntax

How To Use std::make_from_tuple in C++ 17

C++C++17C++20Learn C++

How To Use std::apply With Tuple In C++ 17 And Beyond?

C++C++17C++20Learn C++NumericsSyntax

How To Compute The Greatest Common Divisor And Least Common Multiple in C++?

C++C++17Language FeatureLearn C++

How To Use Skia Shader SkSL Shading Language Code in C++ Builder?