Skip to content

Commit

Permalink
Merge pull request #613 from CaseyCarter/contiguous_empty
Browse files Browse the repository at this point in the history
view::empty is trivially contiguous
  • Loading branch information
ericniebler authored Mar 27, 2017
2 parents 7d82079 + d2c0340 commit 631d728
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/range/v3/view/empty.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ namespace ranges
{
return 0u;
}
constexpr T const *data() const
{
return nullptr;
}
};

namespace view
Expand Down
11 changes: 9 additions & 2 deletions test/span.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
///////////////////////////////////////////////////////////////////////////////

#include <range/v3/span.hpp>
#include "./simple_test.hpp"
#include "./test_utils.hpp"

#include <algorithm>
#include <iostream>
Expand All @@ -37,6 +35,10 @@
#include <string>
#include <vector>

#include <range/v3/view/empty.hpp>
#include "./simple_test.hpp"
#include "./test_utils.hpp"

using namespace ranges;

namespace
Expand Down Expand Up @@ -993,6 +995,11 @@ int main()
(void)cs;
}

{
span<int const> s{ranges::view::empty<int>()};
CHECK(s.empty());
}

test_default_constructor();
test_size_optimization();
test_from_nullptr_constructor();
Expand Down

0 comments on commit 631d728

Please sign in to comment.