GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::experimental::to_array(3) C++ Standard Libary std::experimental::to_array(3)

std::experimental::to_array - std::experimental::to_array


Defined in header <experimental/array>
template <class T, std::size_t N> (library fundamentals TS
constexpr std::array<std::remove_cv_t<T>, N> to_array(T v2)
(&a)[N]);


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.


a - the built-in array to be used to initialize the std::array


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


namespace detail {
template <class T, std::size_t N, std::size_t... I>
constexpr std::array<std::remove_cv_t<T>, N>
to_array_impl(T (&a)[N], std::index_sequence<I...>)
{
return { {a[I]...} };
}
}


template <class T, std::size_t N>
constexpr std::array<std::remove_cv_t<T>, N> to_array(T (&a)[N])
{
return detail::to_array_impl(a, std::make_index_sequence<N>{});
}

// Run this code


#include <cstdlib>
#include <cassert>
#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);
}


make_array Creates a std::array object whose size and optionally
(library fundamentals TS v2) element type are deduced from the arguments
(function template)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.