C++C++17C++20C++23Learn C++Syntax

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

How To Use stdmake from tuple in C++ 17

The  C++ 17 standard was one of the major standards in the history of modern C++. One of the new library features in C++17 was std::make_from_tuple which is a new function template that initializes a value of type T from the elements of a given tuple. In this post, we explain how to apply with std::tuple in C++ examples.

What is std::tuple in C++?

The tuple ( std::tuple) is a class template a fixed-size collection of different types of values like floats, integers, texts, etc. In another term tuple stores the different types of the elements, it also supports empty lists. This template is available since C++11 and improved in C++20 standards.

std::tuple is a generalization of std::pair. The destructor of tuple is trivial if std::is_trivially_destructible<type>::value is set to true for every type in Types.

Here is an example to define different types of members in a tuple, and printing out them,

and the output is,

If you want to know more about std::tuple please check our posts below,

What is std::make_from_tuple in C++?

The make_from_tuple (std::make_from_tuple) is a new function template defined in the <tuple> header that initializes a value of type T from the elements of a given tuple. It is like the apply template applied to a constructor. It can be used with a constructor of a struct or a class.

Syntax of std::make_from_tuple since C++17 until C++23,

Syntax of std::make_from_tuple since C++23,

How to use std::make_from_tuple in C++ 17

Here is a full example that uses our defined print_class constructor with std::make_from_tuple,

Here is the output ,

For more details about this feature in C++17 standard, please see these papers; P0209R2

How To Use stdmake from tuple in C++ 17

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 from here. For professional developers, there are Professional, Architect, or Enterprise versions of C++ Builder and there is a trial version you can download from here.

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.


Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial

Free C++Builder Community Edition

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++11C++14C++17C++20Introduction to C++Learn C++

Learn Copy Constructors in C++ Classes

C++C++11C++14C++17Introduction to C++Learn C++Syntax

Learn How To Use Types Of Destructors In C++?

C++C++11C++14Learn C++Syntax

How To Convert u32string To A wstring In C++

C++C++11C++14C++17C++20Introduction to C++Learn C++

How To Learn The Move Constructors In Modern C++?