byzhang / rapidjson

Automatically exported from code.google.com/p/rapidjson
MIT License
0 stars 0 forks source link

Explicit constructors for GenericValue #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Classic example, 2 functions: 
        AnyType ToAnyType(char const *str);
        AnyType ToAnyType(GenericValue< rapidjson::UTF8<> > const &json);
2. leading ambiguous function call
3.

What is the expected output? What do you see instead?
I expect, that my program will compile in this case 

What version of the product are you using? On what operating system?
Windows 7 Ultimate, rapidjson-0.11

Please provide any additional information below.

Original issue reported on code.google.com by Gom...@gmail.com on 25 Apr 2013 at 6:49

GoogleCodeExporter commented 9 years ago
What's your compiler and the code generating the compilation error?

Original comment by milo...@gmail.com on 18 Jun 2013 at 1:57

GoogleCodeExporter commented 9 years ago
My compiler is MS Visual Studio 2010
I can't repeat compilation error ( I need more time for this ), but here 
another code example:
typedef std::wstring String;
typedef String::value_type Char;

String ToString( Char const *c_str )
{
    return L"c string";
}
String ToString( GenericValue< rapidjson::UTF16<> > const &generic_value )
{
    return L"rapidjson generic value";
}

void foo()
{
    ToString( "hello!" );
}

This code compiles well, but it shouldn't, I think.

Original comment by Gom...@gmail.com on 20 Jun 2013 at 4:21

GoogleCodeExporter commented 9 years ago
Oh, sorry for my mistake, code example:

typedef std::wstring String;
typedef String::value_type Char;

String ToString( String const &str )
{
    return L"c++ string";
}
String ToString( GenericValue< rapidjson::UTF16<> > const &generic_value )
{
    return L"rapidjson generic value";
}

void foo()
{
    ToString( L"hello!" );
}

ambiguous call to overloaded function

Original comment by Gom...@gmail.com on 20 Jun 2013 at 4:43

GoogleCodeExporter commented 9 years ago
Just building the test failed with the same error.  Using g++44 v4.4.7.  
Everything else checks out, only the valuetest.cpp failed with the follow.

$ make -f test.make config=release64
...
...
...

valuetest.cpp
../../test/unittest/valuetest.cpp: In member function ‘virtual void 
Value_Int64_Test::TestBody()’:
../../test/unittest/valuetest.cpp:197: error: call of overloaded 
‘GenericValue(long long int)’ is ambiguous

Original comment by ch...@6waves.com on 12 Sep 2013 at 9:14

GoogleCodeExporter commented 9 years ago
looks like it's fixed at trunk

Original comment by ch...@6waves.com on 12 Sep 2013 at 9:25

GoogleCodeExporter commented 9 years ago
I've not seen a fix in trunk, yet.  I've pushed a fix for this issue to my 
GitHub fork at
https://github.com/pah/rapidjson/commit/b1fcf5318

Original comment by philipp....@gmail.com on 1 Feb 2014 at 6:57

GoogleCodeExporter commented 9 years ago
https://github.com/miloyip/rapidjson/pull/11

Original comment by milo...@gmail.com on 25 Jun 2014 at 4:13