A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://en.cppreference.com/w/cpp/language/../../cpp/header/../experimental/to_array.html below:

std::experimental::to_array - cppreference.com

Merged into ISO C++ The functionality described on this page was merged into the mainline ISO C++ standard as of 7/2019, see std::to_array (since C++20)

Creates a std::array from the built-in array a. The elements of the std::array are copy-initialized from the corresponding element of a.

[edit] Parameters a - the built-in array to be used to initialize the std::array [edit] Return value

An std::array object whose elements are copy-initialized from the corresponding element of a.

[edit] Possible implementation [edit] Example
#include <cassert>
#include <cstdlib>
#include <experimental/array>
#include <unistd.h>
 
// mkstemp(3) that works
template<std::size_t N>
int tempfd(char const (&tmpl)[N])
{
    auto s = std::experimental::to_array(tmpl);
    int fd = mkstemp(s.data());
    if (fd != -1)
        unlink(s.data());
 
    return fd;
}
 
int main()
{
    int fd = tempfd("/tmp/test.XXXXXX");
    int rt = close(fd);
    assert(rt == 0);
}
[edit] See also

(library fundamentals TS v2)

creates a std::array object whose size and optionally element type are deduced from the arguments
(function template) [edit]

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4