Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
array-from-string-literal.hh
Go to the documentation of this file.
1#pragma once
3
4#include <algorithm>
5#include <array>
6
7namespace nix {
8
9template<size_t sizeWithNull>
10struct ArrayNoNullAdaptor
11{
12 std::array<char, sizeWithNull - 1> data;
13
14 constexpr ArrayNoNullAdaptor(const char (&init)[sizeWithNull])
15 {
16 static_assert(sizeWithNull > 0);
17 std::copy_n(init, sizeWithNull - 1, data.data());
18 }
19};
20
21template<ArrayNoNullAdaptor str>
22constexpr auto operator""_arrayNoNull()
23{
24 return str.data;
25}
26
27} // namespace nix