Witam.
Mam pewien problem którego rozwiązania nigdzie nie mogę znaleźć.
Tak wygląda moja klasa:
class Matcher{
public:
Matcher(std::string expr);
~Matcher();
template<typename T> T GetConstant();
const char* GetConstantValue();
private:
union{
std::string str;
char sing;
}constant;
UsedValue UsedVal; //wcześniej jest enum
std::string ConstantValue;
std::stack<std::map<std::string, std::string>> MatcherJuxtaposition;
};
kompilator wykrywa błąd w pliku Matcher.cpp:
#include "Matcher.h"
Matcher::Matcher(std::string expr){
const char* regex="([A-Z]*|([A-Z]|[0-9])*)=(\".+\"|rand\((\s*[0-9]+\s*|(\s*[0-9]+\s*,\s*[0-9]+\s*))\))";
if(!std::regex_match(expr, std::regex(regex){
std::cout<<"\""<<expr<<"\" is incorrect.";
delete regex;
exit(1);
}
char CurrentChar;
std::string constant;
int iterator=0;
do{
CurrentChar=expression[iterator];
expr.erase(0,1);
constant+=CurrentChar;
}while(CurrentChar!='=');
if(constant.length()>1){
this->constant.str=constant;
this->UsedVal = STR;
}
else{
this->constant.sing=constant.c_str();
this->UsedVal = CHAR;
}
delete regex;
}
template<typename T> T Matcher::GetConstant(){
if(this->UsedVal==STR) return this->constant.str;
return this->constant.sing;
}
std::string Matcher::GetConstantValue(){return this->ConstantValue;}
matcher.cpp: In constructor 'Matcher::Matcher(std::__cxx11::string)':
matcher.cpp:4:34: error: use of deleted function 'Matcher::<unnamed union>::<con
structor>()'
Matcher::Matcher(std::string expr){
^
compilation terminated due to -Wfatal-errors.
Nigdzie nie mogę znaleźć rozwiązania mojego problemu. Konstruktor jest normalny, więc nie rozumiem o co chodzi.
Jeśli ktoś mógłby pomóc, byłbym bardzo wdzięczny.
Pozdrawiam, Hiskiel.