I've extracted the sections of my code to show what I believe is causing the error.
typedef unordered_multimap<string , ItemPtr > StringToItemMultiMap;
void Library::multiMapItemWithKeys ( StringToItemMultiMap * map , ItemPtr itemPtr , StringSet keySet )
{
StringSet::iterator it;
for ( it = keySet.begin ( ); it != keySet.end ( ); ++it )
{
pair< string , ItemPtr > aPair ( *it , itemPtr );
map->insert ( aPair );
}
}
I have this operator overload:
bool operator<(const ItemPtr & ip1, const ItemPtr & ip2)
{
bool result;
if ( ip1.getPtr ( )->getTitle ( ).compare ( ip2.getPtr ( )->getTitle ( ) ) < 0 )
result = true;
else
result = false;
return result;
}
This is a typical error:
1>------ Build started: Project: asgmt04, Configuration: Debug Win32 ------
1> Library.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xhash(672): error C2675: unary '++' : 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator
1> C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\unordered_map(632) : see reference to function template instantiation 'void std::_Hash<std::_Umap_traits<_Kty,_Ty,std::_Uhash_compare<_Kty,_Hasher,_Keyeq>,_Alloc,true>>::insert<_Iter>(_Iter,_Iter)' being compiled
1> with
1> [
1> _Kty=std::string
1> , _Ty=ItemPtr
1> , _Hasher=std::hash<CustomType>
1> , _Keyeq=std::equal_to<CustomType>
1> , _Alloc=std::allocator<std::pair<const std::string,ItemPtr>>
1> , _Iter=std::string
1> ]
Anyone know what is going on?
I can not make a call to a method of a class from another class :rewrite the code cocos2d (objective-c) on cocos2d-x (c++)
Error:
c:\program files\microsoft visual studio 11.0\vc\include\xrefwrap(273): error C2562: std::_Pmd_caller<_Ret,_Arg0>::_Call_pmd: функция типа "void", возвращающая значение
1> with
1> [
1> _Ret=void,
1> _Arg0=cocos2d::Object
1> ]
1> c:\program files\microsoft visual studio 11.0\vc\include\xrefwrap(271): см. объявление "std::_Pmd_caller<_Ret,_Arg0>::_Call_pmd"
1> with
1> [
1> _Ret=void,
1> _Arg0=cocos2d::Object
1> ]
Not become fully kidat.Tam 20 more lines of the same
HudLayer.cpp
CCMenuItem *button = CCMenuItemImage::create("1.png","1.png",menu_selector(HelloWorld::createSprite));
HelloWorld.cpp
void HelloWorld::createSprite(CCObject *sender)
{
_sprite->initWithFile("bird.png");
_sprite->setPosition(ccp(x,y));
}
In the IronMan.h you have to declare
static void playClicked();
In the Avenger.cpp you can use this method
CCSize *screenSize = CCDirector::sharedDirector()->getVisibleSize();
CCPoint pointOrigin = CCDirector::sharedDirector()->getVisibleOrigin();
float x = screenSize.width;
float y = screenSize.height;*
CCWidgetLayout* widgetLayout = CCWidgetLayout::create();
addChild(widgetLayout);
CCButton* playButton = CCButton::create("btn1.png", "btn2.png", "btn3.png");
playButton->setPosition(x/1.2f,y/1.5f);
playButton->setClickSelector(this,click_selector(IronMan::playClicked));
widgetLayout->addChild(playButton,1);
You should do like this..
CCMenuItem *button = CCMenuItemImage::create("1.png","1.png",menu_selector(HudLayer::createSpriteMethod));
void HudLayer::createSpriteMethod(CCObject *sender)
{
_helloWorld//assuming you have instance of HelloWorld
_helloWorld->createSprite(sender);
}
for HelloWorld::createSprite.....it should be static method.,nothing good comes from it.
The boost examples for usage of the boost::graph library usually employ a graph like
using namespace boost;
typedef adjacency_list
< vecS, // edge container
vecS, // vertex container
undirectedS,
property<vertex_index_t, int>,
property<edge_index_t, int>
> graph;
and therefore they work very well.
But I have a graph with
typedef adjacency_list
< setS, // edge container
listS, // vertex container
undirectedS,
boost::no_property, // vertex property
boost::no_property // edge property
> graph;
and the algorithms don't work out of the box. In most cases a map for looking up a vertex_descriptor for a particular vertex index (integer value) has to be provided.
I want to check whether my graph is planar and compute a planar embedding of it.
I provide a vertex index map and it does work in that way for e.g. the connected_components algorithm, but obviously not for the boyer_myrvold_planarity_test:
using namespace boost;
typedef adjacency_list
<boost::setS, boost::listS, undirectedS,
boost::no_property, boost::no_property> graph;
typedef boost::graph_traits<graph>::edge_descriptor EdgeDesc;
typedef boost::graph_traits<graph>::vertex_descriptor VertexDesc;
typedef std::map<VertexDesc, size_t> VertexDescMap;
typedef std::map<EdgeDesc, size_t> EdgeDescMap;
typedef boost::graph_traits<graph>::vertex_iterator VertexIterator;
graph K_4;
std::vector<VertexDesc> vertex;
for(int i=0;i < 4; ++i){
VertexDesc v = boost::add_vertex(K_4);
vertex.push_back(v);
}
add_edge(vertex[0], vertex[1], K_4);
add_edge(vertex[0], vertex[2], K_4);
add_edge(vertex[0], vertex[3], K_4);
add_edge(vertex[1], vertex[2], K_4);
add_edge(vertex[1], vertex[3], K_4);
add_edge(vertex[2], vertex[3], K_4);
VertexDescMap vidxMap;
boost::associative_property_map<VertexDescMap> vindexMap(vidxMap);
VertexIterator di, dj;
boost::tie(di, dj) = boost::vertices(K_4);
for(int i = 0; di != dj; ++di,++i){
boost::put(vindexMap, (*di), i);
}
if (boyer_myrvold_planarity_test(
boost::boyer_myrvold_params::graph = K_4,
boost::boyer_myrvold_params::vertex_index_map = vindexMap))
std::cout << "K_4 is planar." << std::endl;
else
std::cout << "ERROR! K_4 should have been recognized as planar!"
<< std::endl;
It results in various cryptic template errors...
> 1>main.cpp
> 1>C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(167)
> : error C2664:
> 'boost::boyer_myrvold_impl<Graph,VertexIndexMap,StoreOldHandlesPolicy,StoreEmbeddingPolicy>::boyer_myrvold_impl(const
> Graph &,VertexIndexMap)': Konvertierung des Parameters 2 von 'const
> boost::adj_list_vertex_property_map<Graph,ValueType,Reference,Tag>' in
> 'vertex_index_map_t' nicht möglich 1> with 1> [ 1>
> Graph=graph_t, 1> VertexIndexMap=vertex_index_map_t, 1>
> StoreOldHandlesPolicy=boost::graph::detail::no_old_handles, 1>
> StoreEmbeddingPolicy=boost::graph::detail::recursive_lazy_list 1>
> ] 1> and 1> [ 1> Graph=graph_t, 1>
> ValueType=boost::detail::error_property_not_found, 1>
> Reference=const boost::detail::error_property_not_found &, 1>
> Tag=boost::vertex_index_t 1> ] 1> Kein
> benutzerdefinierter Konvertierungsoperator verfügbar, der diese
> Konvertierung durchführen kann, oder der Operator kann nicht
> aufgerufen werden 1>
> C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(259):
> Siehe Verweis auf die Instanziierung der gerade kompilierten
> Funktions-template "bool
> boost::boyer_myrvold_params::core::dispatched_boyer_myrvold<ArgumentPack>(const
> ArgumentPack &,boost::mpl::false_,boost::mpl::true_)". 1> with
> 1> [ 1>
> ArgumentPack=boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::embedding,const
> boost::bgl_named_params<boost::associative_property_map<VertexDescMap>,boost::vertex_index_t,boost::no_property>>,boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::graph,const
> boost::adjacency_list<boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property>>,boost::parameter::aux::empty_arg_list>> 1> ] 1>
> C:\Libraries\PCL-1.5.1\3rdParty\Boost\include\boost/graph/boyer_myrvold_planar_test.hpp(281):
> Siehe Verweis auf die Instanziierung der gerade kompilierten
> Funktions-template "bool
> boost::boyer_myrvold_params::core::boyer_myrvold_planarity_test<boost::parameter::aux::arg_list<TaggedArg,Next>>(const ArgumentPack &)". 1> with 1> [ 1>
> TaggedArg=boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::embedding,const
> boost::bgl_named_params<boost::associative_property_map<VertexDescMap>,boost::vertex_index_t,boost::no_property>>,
> 1>
> Next=boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::graph,const
> boost::adjacency_list<boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property>>,boost::parameter::aux::empty_arg_list>, 1>
> ArgumentPack=boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::embedding,const
> boost::bgl_named_params<boost::associative_property_map<VertexDescMap>,boost::vertex_index_t,boost::no_property>>,boost::parameter::aux::arg_list<boost::parameter::aux::tagged_argument<boost::boyer_myrvold_params::tag::graph,const
> boost::adjacency_list<boost::setS,boost::listS,boost::undirectedS,boost::no_property,boost::no_property>>,boost::parameter::aux::empty_arg_list>> 1> ] 1> .\src\main.cpp(135): Siehe Verweis auf die
> Instanziierung der gerade kompilierten Funktions-template "bool
> boost::boyer_myrvold_planarity_test<graph,boost::bgl_named_params<T,Tag,Base>>(const
> A0 &,const A1 &)". 1> with 1> [ 1>
> T=boost::associative_property_map<VertexDescMap>, 1>
> Tag=boost::vertex_index_t, 1> Base=boost::no_property, 1>
> A0=graph, 1>
> A1=boost::bgl_named_params<boost::associative_property_map<VertexDescMap>,boost::vertex_index_t,boost::no_property> 1> ]
In brief, it complains that it cannot convert/use it as I would like it.
How can I make it work?
What else do I have to give to the function?
Unfortunately, there are hardly boost examples for working with setS or listS as containers. Furthermore, I cannot use the property tags because this is part of a larger implementation and I need to keep the properties external.
I would be very happy if somebody has a suggestion.
The error message tells that you need to provide a vertex_index map; see the same problem answered here. Various ways to add the vertex_index map to adjacency_list are discussed here; in fact their problem is almost identical to yours.
In the following protocol buffer, how does one access the repeated fields in the extension from C++?
base.proto
message Base {
optional int32 id = 1;
repeated int32 ids = 2;
optional string name = 3;
repeated string names = 4;
extensions 1000 to 1999;
}
ext.proto
import "base.proto";
extend Base {
repeated string names = 1000;
optional int32 number = 1001;
repeated int32 numbers = 1002;
optional string name = 1003;
}
The following doesn't compile (in VS2010)
#include "base.pb.h"
#include "ext.pb.h"
using namespace ::google::protobuf;
int main(int argc, char *argv[])
{
Base b;
RepeatedPtrField<std::string> base_names = b.names(); // OK
RepeatedField<int> base_ids = b.ids(); // OK
int ext_number = b.GetExtension(number); // OK
std::string ext_name = b.GetExtension(name); // OK
assert( b.HasExtension(numbers) ); // OK
assert( b.HasExtension(names) ); // OK
int32 i = b.GetExtension(numbers); // ? Compiles but doesn't make sense.
RepeatedField<int32> ext_numbers = b.GetExtension(numbers); // compilation fails:
RepeatedPtrField<std::string> ext_names = b.GetExtension(names); // compilation fails:
return 0;
}
Compilation errors
1>test_proto.cpp(17): error C2440: 'initializing' : cannot convert from 'int' to 'google::protobuf::RepeatedField<Element>'
1> with
1> [
1> Element=google::protobuf::int32
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
1>\test_proto.cpp(18): error C2440: 'initializing' : cannot convert from 'const std::string' to 'google::protobuf::RepeatedPtrField<Element>'
1> with
1> [
1> Element=std::string
1> ]
1> No constructor could take the source type, or constructor overload resolution was ambiguous
Thanks to Feng Xiao on the protobuf mailing list, use ExtensionSize(id) and GetExtension(id, index):
Base b;
int index = 0;
if (index < b.ExtensionSize(names))
{
std::string s_value = b.GetExtension(names, index);
}
I want to set a Handle<Value> of an array. I'm a beginner to v8 and i can't found how to set it
when I do for example:
Persistent<Context> fcontext
Handle<Value> Arr = Array::New(0);
Persistent<Function> Func;
Handle<Value> result = Func->Call(fcontext->Global(), 0, Arr);
I receive this error:
error C2664: 'v8::Function::Call' : cannot convert parameter 3 from 'v8::Handle<T>' to 'v8::Handle<T> []'
1> with
1> [
1> T=v8::Value
1> ]
How do I make a Handle<Value> of an array with 1 element ?
const unsigned argc = 1;
Local<Value> argv[argc] = { Local<Value>::New(String::New("Hello World!")) };
func->Call(Context::GetCurrent()->Global(), argc, argv);
More examples:
http://izs.me/v8-docs/examples.html
http://nodejs.org/api/addons.html