Skip to content

Commit

Permalink
Merge pull request #141 from mapbox/match-otherwise
Browse files Browse the repository at this point in the history
Adds a test for polymorphic lambdas in match, resolves #140
  • Loading branch information
artemp committed Feb 20, 2017
2 parents 3d807d3 + 9ac8978 commit 916139a
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/lambda_overload_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,37 @@ void test_match_overloads_capture()
std::cout << "Got " << ok << " ok, " << err << " err" << std::endl;
}

// See #140
void test_match_overloads_otherwise()
#ifdef HAS_CPP14_SUPPORT
{

struct Center
{
};
struct Indent
{
};
struct Justify
{
};
struct None
{
};

using Properties = mapbox::util::variant<Center, Indent, Justify, None>;

Properties props = Justify{};

props.match([&](Center) { std::cout << "Center\n"; }, //
[&](Indent) { std::cout << "Indent\n"; }, //
[&](auto&&) { std::cout << "Otherwise\n"; }); //
}
#else
{
}
#endif

int main()
{
test_lambda_overloads();
Expand All @@ -122,6 +153,7 @@ int main()
test_match_singleton();
test_match_overloads();
test_match_overloads_capture();
test_match_overloads_otherwise();
}

#undef HAS_CPP14_SUPPORT

0 comments on commit 916139a

Please sign in to comment.