mpark / patterns

This is an experimental library that has evolved to P2688
https://wg21.link/p2688
Boost Software License 1.0
666 stars 31 forks source link

Fix compile error in `optional.hpp` #1

Closed Hamdor closed 7 years ago

Hamdor commented 7 years ago

This fixes a compile error in optional.hpp. Example:

#include <iostream>
#include <mpark/match.hpp>

int factorial(int n) {
  using namespace mpark;
  return match(n)(pattern(0) = [] { return 1; },
                  pattern(arg) = [](auto n) { return n * factorial(n - 1); });
}

int main() {
  std::cout << factorial(5) << std::endl;
}

Error:

In file included from test.cpp:4:
In file included from /usr/local/include/mpark/match.hpp:265:
/usr/local/include/mpark/patterns/optional.hpp:46:28: error: default initialization of an object of const type 'const patterns::None' without a user-provided default constructor
  constexpr patterns::None none;
                           ^
                               {}
1 error generated.
mpark commented 7 years ago

Thanks!