When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
19 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
;compile
<source>:2:1: error: 'structure' does not name a type; did you mean 'struct'?
2 | structure MyStructure{
| ^~~~~~~~~
| struct
<source>:10:1: error: '::main' must return 'int'
10 | void main(){
| ^~~~
<source>: In function 'int main()':
<source>:11:9: error: 'MyStructure' was not declared in this scope
11 | auto ms=MyStructure("ABC");
| ^~~~~~~~~~~
<source>:12:22: error: 'vector' was not declared in this scope
12 | auto ms1=MyStructure(vector{1,2,3});
| ^~~~~~
<source>:13:28: error: expected ')' before '{' token
13 | auto ms2=MyStructure(vector{1.0,2.0,3.0});
| ~ ^
| )
Build failed
my code isn't actually correct i just did the idea again with new words and stuff
this is my code gain
;compile c++
<source>: In instantiation of 'RxMatcher<Container>::RxMatcher(const Container&) [with Container = char [16]]':
<source>:15:51: required from here
<source>:12:42: error: array used as initializer
12 | RxMatcher(const Container& pattern): pattern(pattern){}
| ^~~~~~~~~~~~~~~~
Build failed
Its because it doesn’t deduct to std::string but char[16]
A std::string literal should work
;compile
#include <iostream>
#include <string>
#include <set>
#include <vector>
using namespace std;
using namespace std::literals;
template<typename Container>
struct RxMatcher{
Container pattern;
RxMatcher(const string&& pattern): pattern(pattern){}
RxMatcher(const Container& pattern): pattern(pattern){}
};
int main(){
auto matcher = RxMatcher("h((.[a-z])(lo))"s);
auto matcher1 = RxMatcher(vector{1, 10, 20, 4});
auto matcher2 = RxMatcher(vector{ 1.1, 10.0, 4.0 });
return 0;
}```
No output.
It is similar to doing
`auto matcher = RxMatcher(string("texty text"));
is it not possible to force the input to be string from my structure class instead of main
is there no way to deduct that inside the structure itself?
Ou, right. Not changing main was part of the requirement
but still this is huge progress
I don’t think it’s possible to CTAD a std::string template argument from a c string literal