Skip to content

Commit

Permalink
Better way to initialize default value
Browse files Browse the repository at this point in the history
  • Loading branch information
lisitsyn committed Mar 1, 2016
1 parent 798a3ac commit ead7bfa
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/shogun/lib/WrappedBasic.h
Expand Up @@ -39,6 +39,20 @@
#include <shogun/base/SGObject.h>
#include <shogun/lib/SGString.h>

namespace
{
template <typename T>
T default_value()
{
return T();
}

template <>
char default_value()
{
return '0';
}
}

namespace shogun
{
Expand All @@ -55,9 +69,7 @@ template<class T> class CWrappedBasic: public CSGObject
/** Default constructor. Do not use. */
CWrappedBasic() : CSGObject()
{
// use my initials as standard value as XML cannot serialise (char)0
// QUIZ: Who am I?
m_value = 'H';
m_value = ::default_value<T>();
m_value_name = "Unnamed";
set_generic<T>();
register_params();
Expand Down

1 comment on commit ead7bfa

@karlnapf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.