Author
anonymous
almost 7 years ago
Language
C++
Compiler
gcc 8.1.0
Options
Warnings
Boost 1.67.0
C++17(GNU)
no pedantic
Author
anonymous
almost 7 years ago
$ g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.67.0/gcc-8.1.0/include -std=gnu++17
prog.cc: In function 'int main()':
prog.cc:13:38: error: 'constexpr std::array<int, N> createTable() [with int N = 1]' called in a constant expression
constexpr auto t1 = createTable<1>();
^
prog.cc:4:37: note: 'constexpr std::array<int, N> createTable() [with int N = 1]' is not usable as a 'constexpr' function because:
constexpr static std::array<int, N> createTable() {
^~~~~~~~~~~
prog.cc:7:6: error: call to non-'constexpr' function 'std::array<_Tp, _Nm>::value_type& std::array<_Tp, _Nm>::operator[](std::array<_Tp, _Nm>::size_type) [with _Tp = int; long unsigned int _Nm = 1; std::array<_Tp, _Nm>::reference = int&; std::array<_Tp, _Nm>::value_type = int; std::array<_Tp, _Nm>::size_type = long unsigned int]'
a[i] = i;
~^
prog.cc:14:38: error: 'constexpr std::array<int, N> createTable() [with int N = 1]' called in a constant expression
constexpr auto t2 = createTable<1>();
^
prog.cc:15:23: error: non-constant condition for static assertion
static_assert(t1[0] == t2[0], "can build.");
Exit Code:
1