Skip to content

Instantly share code, notes, and snippets.

@sanuj
Created May 28, 2016 10:48
Show Gist options
  • Save sanuj/d58a90e327516c11449cfba597e62316 to your computer and use it in GitHub Desktop.
Save sanuj/d58a90e327516c11449cfba597e62316 to your computer and use it in GitHub Desktop.

In SGObject.h:

class CSGObject {
  ...
  private:
    ...
    struct Self;
    DPtr<Self> self;
  ...
}

In SGObject.cpp:

struct CSGObject::Self
{
	void set(int tag_id, const Any& any)
	{
		map[tag_id] = any;
	}
	Any get(int tag_id)
	{
		return map.at(tag_id);
	}
	std::unordered_map<int, Any> map;
};

CSGObject::CSGObject() : self()
{
	init();
	set_global_objects();
	m_refcount = new RefCount(0);

	SG_SGCDEBUG("SGObject created (%p)\n", this)
}

CSGObject::CSGObject(const CSGObject& orig)
: io(orig.io), parallel(orig.parallel), version(orig.version), self()
{
	init();
	set_global_objects();
	m_refcount = new RefCount(0);

	SG_SGCDEBUG("SGObject copied (%p)\n", this)
}

Error while building:

In file included from /home/sanuj/Projects/shogun/src/shogun/base/class_list.cpp:292:0:
/home/sanuj/Projects/shogun/src/shogun/transfer/multitask/MultitaskKernelTreeNormalizer.h: In constructor ‘shogun::CMultitaskKernelTreeNormalizer::CMultitaskKernelTreeNormalizer(std::vector<std::basic_string<char> >, std::vector<std::basic_string<char> >, shogun::CTaxonomy)’:
/home/sanuj/Projects/shogun/src/shogun/transfer/multitask/MultitaskKernelTreeNormalizer.h:400:12: error: use of deleted function ‘shogun::CTaxonomy& shogun::CTaxonomy::operator=(const shogun::CTaxonomy&)’
   taxonomy = tax;
            ^
In file included from /home/sanuj/Projects/shogun/src/shogun/base/class_list.cpp:292:0:
/home/sanuj/Projects/shogun/src/shogun/transfer/multitask/MultitaskKernelTreeNormalizer.h:146:7: note: ‘shogun::CTaxonomy& shogun::CTaxonomy::operator=(const shogun::CTaxonomy&)’ is implicitly deleted because the default definition would be ill-formed:
 class CTaxonomy : public CSGObject
       ^
/home/sanuj/Projects/shogun/src/shogun/transfer/multitask/MultitaskKernelTreeNormalizer.h:146:7: error: use of deleted function ‘shogun::CSGObject& shogun::CSGObject::operator=(const shogun::CSGObject&)’
In file included from /home/sanuj/Projects/shogun/src/shogun/machine/Machine.h:18:0,
                 from /home/sanuj/Projects/shogun/src/shogun/machine/BaggingMachine.h:16,
                 from /home/sanuj/Projects/shogun/src/shogun/machine/RandomForest.h:35,
                 from /home/sanuj/Projects/shogun/src/shogun/base/class_list.cpp:15:
/home/sanuj/Projects/shogun/src/shogun/base/SGObject.h:120:7: note: ‘shogun::CSGObject& shogun::CSGObject::operator=(const shogun::CSGObject&)’ is implicitly deleted because the default definition would be ill-formed:
 class CSGObject
       ^
/home/sanuj/Projects/shogun/src/shogun/base/SGObject.h:120:7: error: use of deleted function ‘shogun::DPtr<shogun::CSGObject::Self>& shogun::DPtr<shogun::CSGObject::Self>::operator=(const shogun::DPtr<shogun::CSGObject::Self>&)’
In file included from /home/sanuj/Projects/shogun/src/shogun/lib/context.h:5:0,
                 from /home/sanuj/Projects/shogun/src/shogun/base/SGObject.h:23,
                 from /home/sanuj/Projects/shogun/src/shogun/machine/Machine.h:18,
                 from /home/sanuj/Projects/shogun/src/shogun/machine/BaggingMachine.h:16,
                 from /home/sanuj/Projects/shogun/src/shogun/machine/RandomForest.h:35,
                 from /home/sanuj/Projects/shogun/src/shogun/base/class_list.cpp:15:
/home/sanuj/Projects/shogun/src/shogun/lib/dptr.h:46:11: note: ‘shogun::DPtr<shogun::CSGObject::Self>& shogun::DPtr<shogun::CSGObject::Self>::operator=(const shogun::DPtr<shogun::CSGObject::Self>&)’ is implicitly deleted because the default definition would be ill-formed:
     class DPtr : public std::unique_ptr<T>
           ^
/home/sanuj/Projects/shogun/src/shogun/lib/dptr.h:46:11: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>& std::unique_ptr<_Tp, _Dp>::operator=(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = shogun::CSGObject::Self; _Dp = std::default_delete<shogun::CSGObject::Self>]’
In file included from /usr/include/c++/4.8/memory:81:0,
                 from /home/sanuj/Projects/shogun/src/shogun/lib/dptr.h:41,
                 from /home/sanuj/Projects/shogun/src/shogun/lib/context.h:5,
                 from /home/sanuj/Projects/shogun/src/shogun/base/SGObject.h:23,
                 from /home/sanuj/Projects/shogun/src/shogun/machine/Machine.h:18,
                 from /home/sanuj/Projects/shogun/src/shogun/machine/BaggingMachine.h:16,
                 from /home/sanuj/Projects/shogun/src/shogun/machine/RandomForest.h:35,
                 from /home/sanuj/Projects/shogun/src/shogun/base/class_list.cpp:15:
/usr/include/c++/4.8/bits/unique_ptr.h:274:19: error: declared here
       unique_ptr& operator=(const unique_ptr&) = delete;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment