fork(1) download
  1. #include <array>
  2. #include <functional>
  3.  
  4. std::array<std::function<void()>, 5> array;
  5. static_assert(sizeof(array) == sizeof(std::function<void()>) * 5, "Works!");
  6. static_assert(array.size() == 5, "Fails?");
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:6:1: error: non-constant condition for static assertion
 static_assert(array.size() == 5, "Fails?");
 ^~~~~~~~~~~~~
prog.cpp:6:25: error: call to non-constexpr function ‘constexpr std::array<_Tp, _Nm>::size_type std::array<_Tp, _Nm>::size() const [with _Tp = std::function<void()>; long unsigned int _Nm = 5ul; std::array<_Tp, _Nm>::size_type = long unsigned int]’
 static_assert(array.size() == 5, "Fails?");
               ~~~~~~~~~~^~
In file included from prog.cpp:1:0:
/usr/include/c++/6/array:171:7: note: ‘constexpr std::array<_Tp, _Nm>::size_type std::array<_Tp, _Nm>::size() const [with _Tp = std::function<void()>; long unsigned int _Nm = 5ul; std::array<_Tp, _Nm>::size_type = long unsigned int]’ is not usable as a constexpr function because:
       size() const noexcept { return _Nm; }
       ^~~~
/usr/include/c++/6/array:171:7: error: enclosing class of constexpr non-static member function ‘constexpr std::array<_Tp, _Nm>::size_type std::array<_Tp, _Nm>::size() const [with _Tp = std::function<void()>; long unsigned int _Nm = 5ul; std::array<_Tp, _Nm>::size_type = long unsigned int]’ is not a literal type
/usr/include/c++/6/array:90:12: note: ‘std::array<std::function<void()>, 5ul>’ is not literal because:
     struct array
            ^~~~~
/usr/include/c++/6/array:90:12: note:   ‘std::array<std::function<void()>, 5ul>’ has a non-trivial destructor
stdout
Standard output is empty