Comments (10)
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 make_span
is not defined by the standard
from matio-cpp.
std::ranges::range_reference_t
Ah I see. The problem is that std::ranges
is C++20 (https://en.cppreference.com/w/cpp/ranges)
from matio-cpp.
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 std::span
will be more accessible
from matio-cpp.
Yes, the relevant error is
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:411:24: note: candidate: ātemplate<class ElementType, long int Extent, class Container, class, class> Span(const Container&)-> matioCpp::Span<ElementType, Extent>ā
411 | MATIOCPP_CONSTEXPR Span(const Container& cont) : Span(cont.data(), static_cast<index_type>(cont.size()))
| ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:411:24: note: template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note: couldnāt deduce template parameter āElementTypeā
44 | matioCpp::Span s{v};
| ^
In file included from /home/gromualdi/robot-code/yarp-telemetry/src/libYARP_telemetry/src/yarp/telemetry/experimental/Record.h:12,
from /home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:14:
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:402:24: note: candidate: ātemplate<class ElementType, long int Extent, class Container, class, class> Span(Container&)-> matioCpp::Span<ElementType, Extent>ā
402 | MATIOCPP_CONSTEXPR Span(Container& cont) : Span(cont.data(), static_cast<index_type>(cont.size()))
| ^~~~
/home/gromualdi/robot-code/robotology-superbuild/build/install/include/matioCpp/Span.h:402:24: note: template argument deduction/substitution failed:
/home/gromualdi/robot-code/yarp-telemetry/src/examples/circular_buffer_record_example.cpp:44:27: note: couldnāt deduce template parameter āElementTypeā
As you noticed, it fails to deduce the ElementType
.
I am not sure I understood what you meant in
In this case the used deduction guides used should be:
template<class R> span(R&&) -> span<std::remove_reference_t<std::ranges::range_reference_t<R>>>;
from matio-cpp.
I am not sure I understood what you meant in
In this case the used deduction guides used should be:
template<class R> span(R&&) -> span<std::remove_reference_t<std::ranges::range_reference_t<R>>>;
Accordingly to what is written here
the deduction guide used for std::vector
is
from matio-cpp.
This implementation seems able to perform the deduction. https://github.com/martinmoene/span-lite
What do you think to port it matio-cpp?
from matio-cpp.
Before taking any decision let me try in a toy problem š
from matio-cpp.
The following code works with span-line
#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, } );
}
from matio-cpp.
I tried to edit the SpanUnitTest
as follows
But I am able to compile š¤
from matio-cpp.
See 708827b
from matio-cpp.
Related Issues (20)
- If the matio class is MAT_C_CHAR, the value type is forced to UTF8
- [Not an issue] AUR packages HOT 1
- Test issue for auto assignement HOT 1
- Yet another test issue HOT 1
- Some tests failed after new matio release HOT 1
- String16 and String32 do not have the assignement operator from the corresponding strings HOT 1
- Add path/name of the file that matio-cpp failed to create HOT 1
- Reading in sparse matrix HOT 1
- Generated matfile are not hdf5 compatible HOT 7
- Investigate the possibility of automatically converting a struct into a matioCpp struct using reflection HOT 1
- Add system tests for reading/writing in matlab HOT 1
- *.tpp files throw syntax error HOT 16
- Build errors with MSVC /permissive- flag HOT 2
- Problem with linking library HOT 13
- Memory problem HOT 3
- Test #11 failing HOT 2
- Thread Safety HOT 3
- Tests fail on Windows HOT 2
- Cannot read mat files saved from Python with `7.3` format HOT 15
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matio-cpp.