#include "CtrlLib/CtrlLib.h" using namespace Upp; #define LAYOUTFILE <Cpp11/Cpp11.lay> #include <CtrlCore/lay.h> GUI_APP_MAIN { WithMyAppLayout<TopWindow> dlg; CtrlLayout(dlg, "C++11 demo"); dlg.list.NoHeader().AddColumn(); Vector<int> x = { 1, 2, 12, 34, 15, 11 }; for(auto i : x) dlg.list.Add(i); dlg.add << [&] { if(dlg.list.Find(~dlg.number) < 0) dlg.list.Add(~dlg.number); }; dlg.list.WhenSel << [&] { dlg.number <<= dlg.list.GetKey(); }; dlg.Execute(); }
struct GLTextureDescriptor : Moveable<GLTextureDescriptor> { int w,h,wTex,hTex; struct GLTex : Moveable<GLTex> { int w,h; GLuint glId; }; Vector<Vector<GLTex>> glTex; }; VectorMap<String,GLTextureDescriptor> glTextureDescriptors; //... GLTextureDescriptor desc; //... glTextureDescriptors.AddPick(key, desc); // <-- compiler error, cannot cast 2nd argument to GLTextureDescriptor &&
One<MFile> mfile; One<MFile> cur_mfile(new MFile); mfile = cur_mfile; // <-- Upp::One<MFile> &Upp::One<MFile>::operator =(const Upp::One<MFile> &)': attempting to reference a deleted function
mfile = cur_mfile.Detach();
Still having rare issues with newest C++11-style code:
struct GLTextureDescriptor : Moveable<GLTextureDescriptor> { int w,h,wTex,hTex; struct GLTex : Moveable<GLTex> { int w,h; GLuint glId; }; Vector<Vector<GLTex>> glTex; }; VectorMap<String,GLTextureDescriptor> glTextureDescriptors; //... GLTextureDescriptor desc; //... glTextureDescriptors.AddPick(key, desc); // <-- compiler error, cannot cast 2nd argument to GLTextureDescriptor &&
I wasn't able to find quick & easy solution for this case.
There is another C++11 problem. Checked with MSVC2015.
One<MFile> mfile; One<MFile> cur_mfile(new MFile); mfile = cur_mfile; // <-- Upp::One<MFile> &Upp::One<MFile>::operator =(const Upp::One<MFile> &)': attempting to reference a deleted function
I need to detach value explicitly.
mfile = cur_mfile.Detach();
Thanks.
Same thing... mfile = pick(cur_mfile).
Simple: You now need to be explicit, except for temporaries.
Bit more verbose, but in fact I was able to find some bugs at compile time already thanks to this..
code\gui\upp\trunk\uppsrc\core\map.h(178) : warning C4717: 'Upp::AMap<int,Upp::Vector<int>,Upp::Vector<Upp::Vector<int> > >::FindPutPick': recursive on all control paths, function will cause runtime stack overflow
FindPutPick(const K& k, T&& init) { return FindPut(k, pick(init)); }
template <class K, class T, class V> int AMap<K, T, V>::FindPut(const K& k, T&& init) { unsigned hash = key.hashfn(k); int i = Find(k, hash); if(i < 0) { i = key.Put(k, hash); value.At(i) = pick(init); } return i; }
VectorMap<int, Vector<int> > x; x.FindPut(1, Vector<int>());
Thanks, you are completely correct.
(BTW, perhaps you have some testing code now - if yes, I can add it to nightly tests, just send it to me).