diff --git a/include/cpp-json/value.h b/include/cpp-json/value.h index de1e108..3040105 100644 --- a/include/cpp-json/value.h +++ b/include/cpp-json/value.h @@ -48,11 +48,9 @@ class value { value(const char *s); value(const object &o); value(std::string s); - value(double x); - value(float x); - value(int x); - value(long x); - value(const std::nullptr_t &); + template>> + value(T n); + value(const std::nullptr_t &); public: value(); diff --git a/include/cpp-json/value.tcc b/include/cpp-json/value.tcc index 8726018..1596eab 100644 --- a/include/cpp-json/value.tcc +++ b/include/cpp-json/value.tcc @@ -73,29 +73,9 @@ inline value::value(std::string s) : type_(type_string) { //------------------------------------------------------------------------------ // Name: value //------------------------------------------------------------------------------ -inline value::value(double x) : type_(type_number) { - new (&value_) std::string(std::to_string(x)); -} - -//------------------------------------------------------------------------------ -// Name: value -//------------------------------------------------------------------------------ -inline value::value(float x) : type_(type_number) { - new (&value_) std::string(std::to_string(x)); -} - -//------------------------------------------------------------------------------ -// Name: value -//------------------------------------------------------------------------------ -inline value::value(long x) : type_(type_number) { - new (&value_) std::string(std::to_string(x)); -} - -//------------------------------------------------------------------------------ -// Name: value -//------------------------------------------------------------------------------ -inline value::value(int x) : type_(type_number) { - new (&value_) std::string(std::to_string(x)); +template +value::value(T n) : type_(type_number) { + new (&value_) std::string(std::to_string(x)); } //------------------------------------------------------------------------------