[ 
https://issues.apache.org/jira/browse/MESOS-939?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13880539#comment-13880539
 ] 

Charlie Carson commented on MESOS-939:
--------------------------------------

slight complication.  there is ambiguity between the constructor I would add:
  Boolean(bool _value)

and the existing constructor for String
  String(const char *_value)

b/c a bool can be initialized w/ a pointer (so you can do things like 
if(m_pointer)).

that means that Boolean constructor needs to be explicit in order to even 
compile.  that doesn't help the problem I'm trying to solve though, b/c the 
implicit conversion of bool->double still fires if you forget to be explicit 
and say JSON::Boolean in the below:

JSON::Object o = JSON::Boolean(true);

then it still compiles and still gives you the double.

so... I'm going to go ahead and add JSON::Boolean as before, w/ the explicit 
constructor.  I'm also going to rename Object to be _Object and create my own 
Object class that inherits from _Object.  I'll then consolidate all the current 
constructors onto Object and have it explicitly forward the proper type to 
_Object.

btw - I'll probably name _Object something better and stick it in an internal 
namespace.




> assignment of bool to Stout JSON::Value yields JSON::Double
> -----------------------------------------------------------
>
>                 Key: MESOS-939
>                 URL: https://issues.apache.org/jira/browse/MESOS-939
>             Project: Mesos
>          Issue Type: Bug
>            Reporter: Charlie Carson
>            Assignee: Charlie Carson
>            Priority: Minor
>
> JSON::Value b = false; goes through the JSON::Double constructor and yields 0 
> instead of false when you serialize.
> 1 solution would be to create a common super type JSON::Boolean which w/ bool 
> field and an implicit constructor ala JSON::String & JSON::Double.
> I'm happy to fix this but wanted some input on if that was the best solution 
> first.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to