Hi
I trying to implement "properties" in C++ (similar to Dephi or C++
Builder). It is almost complete, but I have silly problem. Problem is
with automatic cast from Property class to property type class. This not
happen for every types - for example int works as expected. But
std::string fail for not reimplemented operators. I can overcome this
problem by:
static_cast<std::string&>(lObject.mStringProperty)
, but it is talkative and cumber some and I feel awful when I program
like this.
So, something like this not compile at all:
lObject.mStringProperty += std::string(" A to dopiero!!!"); // Failed
with g++
Error is:
/home/szyk/!-EnergoKod/!-Libs/EnergoKodProperty/Tests/Src/Main.cpp: In
function ‘int main()’:
/home/szyk/!-EnergoKod/!-Libs/EnergoKodProperty/Tests/Src/Main.cpp:81:29:
error: no match for ‘operator+=’ (operand types are
‘Property<WithProperties, std::__cxx11::basic_string<char> >’ and
‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’)
lObject.mStringProperty += std::string(" A to dopiero!!!"); //
Failed with g++
~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
But some thing like this:
lObject.mIntProperty += 1;
Works fine!
If you are interested and if you can help me please clone this tiny
Cmake project from
github.com:
https://github.com/SzykCech4/EnergoKodProperty.git
Note: That project contain Tests subdir with test project - you should
enable BUILD_TESTS option in main CMakeLists.txt in order to compile
this simple test.
thanks in advance and best regards
Szyk Cech