-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing deduction guides for Span object #51
Comments
with this std::vector<int32_t> v{2};
matioCpp::Span<int32_t> s{v}; everything works fine It is nice to have this deduction guide since it will allow to write the following code void foo(Span<int> s);
std::vector<int> v{1};
foo(v); right now what we should do is void foo(Span<int> s);
std::vector<int> v{1};
foo(make_span(v)); Notice that |
Yes, the relevant error is
As you noticed, it fails to deduce the I am not sure I understood what you meant in
|
Accordingly to what is written here |
Ah I see. The problem is that |
This implementation seems able to perform the deduction. https://github.com/martinmoene/span-lite What do you think to port it matio-cpp? |
Before taking any decision let me try in a toy problem 😃 |
The following code works with #include "nonstd/span.hpp"
#include <array>
#include <vector>
#include <iostream>
std::ptrdiff_t size( nonstd::span<const int> spn )
{
return spn.size();
}
int main()
{
int arr[] = { 1, };
std::cout <<
"C-array:" << size( arr ) <<
" array:" << size( std::array <int, 2>{ 1, 2, } ) <<
" vector:" << size( std::vector<int >{ 1, 2, 3, } );
} |
I would say that before moving to a completely new implementation, I would like to understand if it is possible to fix the current implementation. Moving to a new implementation of span might be potentially a lot of work (also for those applications depending on this). I would rather do this step only once, when |
I tried to edit the But I am able to compile 🤔 |
See 708827b |
Accordingly to the
std
documentation the following code should workHowever when I try to compile the code I got
In this case the used deduction guides used should be:
The text was updated successfully, but these errors were encountered: