MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / stdspan

Function stdspan

test/cfg/std.cpp:4930–4972  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4928#warning "This compiler does not support std::span"
4929#else
4930void stdspan()
4931{
4932
4933 std::vector<int> vec{1,2,3,4};
4934 std::span spn{vec};
4935 // cppcheck-suppress unreadVariable
4936 std::span spn2 = spn;
4937
4938 //cppcheck-suppress ignoredReturnValue
4939 spn.begin();
4940 //cppcheck-suppress ignoredReturnValue
4941 spn.end();
4942 //cppcheck-suppress ignoredReturnValue
4943 spn.rbegin();
4944
4945 //cppcheck-suppress ignoredReturnValue
4946 spn.front();
4947 //cppcheck-suppress ignoredReturnValue
4948 spn.back();
4949 //cppcheck-suppress constStatement
4950 spn[0];
4951 //cppcheck-suppress ignoredReturnValue
4952 spn.data();
4953 //cppcheck-suppress ignoredReturnValue
4954 spn.size();
4955 //cppcheck-suppress ignoredReturnValue
4956 spn.size_bytes();
4957 //cppcheck-suppress ignoredReturnValue
4958 spn.empty();
4959 //cppcheck-suppress ignoredReturnValue
4960 spn.first(2);
4961 //cppcheck-suppress ignoredReturnValue
4962 spn.last(2);
4963 //cppcheck-suppress ignoredReturnValue
4964 spn.subspan(1, 2);
4965 spn.subspan<1>();
4966
4967 static constexpr std::array<int, 2> arr{1, 2};
4968 constexpr std::span spn3{arr};
4969 spn3.first<1>();
4970 spn3.last<1>();
4971 spn3.subspan<1, 1>();
4972}
4973
4974std::span<const int> returnDanglingLifetime_std_span0() {
4975 static int a[10]{};

Callers

nothing calls this directly

Calls 6

frontMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected