Skip to content

Commit 7ba2c54

Browse files
author
Billy Donahue
committed
Improve comments on arithmetic type constructor and helper traits.
1 parent 021f7de commit 7ba2c54

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

include/json/value.h

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,12 @@ class JSON_API StaticString {
8585
const char* str_;
8686
};
8787

88-
// Some helper traits for Json::Value
88+
// Some Json::Value helpers in lieu of C++11 <type_traits>.
8989
namespace Detail {
9090

9191
template <typename T>
9292
struct IsIntegral {
93-
enum { value = std::numeric_limits<T>::is_specialized &&
94-
std::numeric_limits<T>::is_integer };
93+
enum { value = std::numeric_limits<T>::is_integer };
9594
};
9695

9796
template <typename T>
@@ -236,6 +235,21 @@ Json::Value obj_value(Json::objectValue); // {}
236235
*/
237236
Value(ValueType type = nullValue);
238237

238+
/** \brief Accept any arithmetic 'T'.
239+
*
240+
* Selected by substitution failure (sfinae) on dummy argument.
241+
* Arithmetic means built-in integral or floating point type.
242+
* This is currently determined with std::numeric_traits.
243+
* Example:
244+
* \code
245+
* Json::Value v[] = {
246+
* Json::Value(my_vector.size()),
247+
* Json::Value(array_last - array_first),
248+
* Json::Value('x'),
249+
* Json::Value(3.14)
250+
* };
251+
* \endcode
252+
*/
239253
template <typename T>
240254
Value(T value, typename Detail::EnableIfArithmetic<T>::type = 0)
241255
: allocated_(false),

0 commit comments

Comments
 (0)