简体   繁体   English

错误:没有匹配函数调用带有union_set的'get(long unsigned int *&,long unsigned int&)'

[英]error: no matching function for call to ‘get(long unsigned int*&, long unsigned int&)’ with union_set

This code 这段代码

table_edges[ this_relationship ] = boost::add_edge(
    table_vertices[ string( foreign_keys[i]["parent_table"].c_str() ) ], 
    table_vertices[ string( foreign_keys[i]["child_table"].c_str() ) ], 
    this_relationship, 
    rg
).first;
ds.union_set( 
    table_vertices[ string( foreign_keys[i]["parent_table"].c_str() ) ],
    table_vertices[ string( foreign_keys[i]["child_table"].c_str() ) ] 
);

gives this error and many others regarding get 给出了这个错误以及许多其他有关获取的信息

/usr/include/boost/pending/detail/disjoint_sets.hpp:59:33: error: no matching function for call to 'get(long unsigned int*&, long unsigned int&)' /usr/include/boost/pending/detail/disjoint_sets.hpp:59:33:错误:没有匹配的函数调用'get(long unsigned int *&,long unsigned int&)'

I am using bundled properties. 我正在使用捆绑的属性。

typedef boost::adjacency_list < 
   boost::vecS, 
   boost::vecS, 
   boost::undirectedS, 
   string, 
   foreign_key_relationship  
> relational_graph;

The rank & parent typedefs are declared globally. rank和父typedef是全局声明的。

How can this error be resolved? 如何解决此错误?


struct foreign_key_relationship{
    string parent_table;
    string parent_column;
    string child_table;
    string child_column;

    foreign_key_relationship(){}

    foreign_key_relationship( string pt, string pc, string ct, string cc ) : parent_table( pt ), parent_column( pc ), child_table( ct ), child_column( cc ) {}

};

inline bool operator==(const foreign_key_relationship& lhs, const foreign_key_relationship& rhs)
{
    return 
        lhs.parent_table == rhs.parent_table 
        && lhs.parent_column == rhs.parent_column 
        && lhs.child_table == rhs.child_table 
        && lhs.child_column == rhs.child_column 
    ;
}

inline bool operator<(const foreign_key_relationship& lhs, const foreign_key_relationship& rhs)
{
    return 
        lhs.parent_table < rhs.parent_table 
        && lhs.parent_column < rhs.parent_column 
        && lhs.child_table < rhs.child_table 
        && lhs.child_column < rhs.child_column 
    ;
}

typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS, string, foreign_key_relationship  > relational_graph;
typedef boost::graph_traits<relational_graph>::vertex_descriptor relational_vertex;
typedef boost::graph_traits<relational_graph>::vertices_size_type relational_vertex_index;
typedef boost::graph_traits<relational_graph>::edge_descriptor relational_edge;
typedef relational_vertex_index* relational_rank;
typedef relational_vertex* relational_parent;

void libpqxx_error( const pqxx_exception &e ){
    cerr << "*** Caught pqxx_exception:\n";
    cerr << e.base().what() << "\n";
    const sql_error *s=dynamic_cast<const sql_error*>(&e.base());
    if (s) std::cerr << "Query was: " << s->query() << "\n";
}

void connect_relational_vertices( map< foreign_key_relationship, relational_edge > &table_edges, result &foreign_keys, set<string> &tables_to_connect, map< string, relational_vertex > &table_vertices, relational_graph &rg, boost::disjoint_sets<relational_rank, relational_parent> &ds ){
    for( unsigned i=0; i<foreign_keys.size(); i++ ){
        foreign_key_relationship this_relationship(
            foreign_keys[i]["parent_table"].c_str(),
            foreign_keys[i]["parent_column"].c_str(),
            foreign_keys[i]["child_table"].c_str(),
            foreign_keys[i]["child_column"].c_str()
        );
        if( !table_edges.count( this_relationship ) && tables_to_connect.count( foreign_keys[i]["parent_table"].c_str() ) && tables_to_connect.count( foreign_keys[i]["child_table"].c_str() ) ){
            table_edges[ this_relationship ] = boost::add_edge(
                table_vertices[ string( foreign_keys[i]["parent_table"].c_str() ) ], 
                table_vertices[ string( foreign_keys[i]["child_table"].c_str() ) ], 
                this_relationship, 
                rg
            ).first;
            ds.union_set( table_vertices[ string( foreign_keys[i]["parent_table"].c_str() ) ], table_vertices[ string( foreign_keys[i]["child_table"].c_str() ) ] );
        }
    }
}

void add_possible_linking_vertex( result &foreign_keys, map< string, relational_vertex > &table_vertices, relational_graph &rg ){
    for( unsigned i=0; i<foreign_keys.size(); i++ ){
        if( !table_vertices.count( foreign_keys[i]["parent_table"].c_str() ) ){
            table_vertices[ foreign_keys[i]["parent_table"].c_str() ] = boost::add_vertex( foreign_keys[i]["parent_table"].c_str(), rg );
            break;
        }
        if( foreign_keys[i]["child_table"].c_str() ){
            table_vertices[ foreign_keys[i]["child_table"].c_str() ] = boost::add_vertex( foreign_keys[i]["child_table"].c_str(), rg );
            break;
        }
    }
}    

set< foreign_key_relationship > get_foreign_keys( transaction_base &t, set<string> tables_to_connect ){
    try{
        result foreign_keys = t.prepared("get_foreign_keys").exec();

        set< foreign_key_relationship > relational_routes;

        if( tables_to_connect.size() ){

            relational_graph rg;

            map< string, relational_vertex > table_vertices;
            for( string table: tables_to_connect )
                table_vertices[ table ] = boost::add_vertex( table, rg );

            std::vector<relational_vertex_index> rank( num_vertices(rg) );
            std::vector<relational_vertex> parent( num_vertices(rg) );

            boost::disjoint_sets<relational_rank, relational_parent> ds(&rank[0], &parent[0]);

            boost::initialize_incremental_components(rg, ds);
            boost::incremental_components(rg, ds);

            map< foreign_key_relationship, relational_edge > table_edges;
            for( unsigned i=0; i<foreign_keys.size(); i++ )
                connect_relational_vertices( table_edges, foreign_keys, tables_to_connect, table_vertices, rg, ds );

        }

        return relational_routes;
    }
    catch( const pqxx_exception &e ){
        libpqxx_error( e );
        set< foreign_key_relationship > relational_routes;
        return relational_routes;
    }
}

I am using libpqxx, and the query to find all foreign key relationships is here . 我正在使用libpqxx, 这里是查找所有外键关系的查询。

I have just spent ~15 minute to add the missing bits to the sample code. 我刚刚花了大约15分钟的时间将丢失的位添加到示例代码中。 I was gonna edit the question and leave a comment, "sadly I ran out of time to look at your actual question". 我要编辑问题并留下评论,“很遗憾,我没有时间来查看您的实际问题”。

However, then it struck me that the actual question was "why does it not compile"? 但是,然后让我吃惊的是,实际的问题是“为什么不编译”?

Well then, it compiles for me, so maybe this will help you figure out what's different none-the-less? 好吧,它为我编译了,所以也许这可以帮助您弄清楚到底有什么不同?

#include <boost/graph/use_mpi.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/distributed/dehne_gotz_min_spanning_tree.hpp>
#include <boost/graph/incremental_components.hpp>
#include <iostream>
#include <pqxx/except.hxx>
#include <pqxx/transaction_base.hxx>
#include <set>
#include <map>
#include <string>

using std::string;
using std::set;
using std::map;
using namespace pqxx;

struct foreign_key_relationship{
    string parent_table;
    string parent_column;
    string child_table;
    string child_column;

    foreign_key_relationship(){}

    foreign_key_relationship( string pt, string pc, string ct, string cc ) : parent_table( pt ), parent_column( pc ), child_table( ct ), child_column( cc ) {}

};

inline bool operator==(const foreign_key_relationship& lhs, const foreign_key_relationship& rhs)
{
    return 
        lhs.parent_table == rhs.parent_table 
        && lhs.parent_column == rhs.parent_column 
        && lhs.child_table == rhs.child_table 
        && lhs.child_column == rhs.child_column 
    ;
}

inline bool operator<(const foreign_key_relationship& lhs, const foreign_key_relationship& rhs)
{
    return 
        lhs.parent_table < rhs.parent_table 
        && lhs.parent_column < rhs.parent_column 
        && lhs.child_table < rhs.child_table 
        && lhs.child_column < rhs.child_column 
    ;
}

typedef boost::adjacency_list < boost::vecS, boost::vecS, boost::undirectedS, string, foreign_key_relationship  > relational_graph;
typedef boost::graph_traits<relational_graph>::vertex_descriptor relational_vertex;
typedef boost::graph_traits<relational_graph>::vertices_size_type relational_vertex_index;
typedef boost::graph_traits<relational_graph>::edge_descriptor relational_edge;
typedef relational_vertex_index* relational_rank;
typedef relational_vertex* relational_parent;

void libpqxx_error( const pqxx_exception &e ){
    std::cerr << "*** Caught pqxx_exception:\n";
    std::cerr << e.base().what() << "\n";
    const sql_error *s=dynamic_cast<const sql_error*>(&e.base());
    if (s) std::cerr << "Query was: " << s->query() << "\n";
}

void connect_relational_vertices( map< foreign_key_relationship, relational_edge > &table_edges, result &foreign_keys, set<string> &tables_to_connect, map< string, relational_vertex > &table_vertices, relational_graph &rg, boost::disjoint_sets<relational_rank, relational_parent> &ds ){
    for( unsigned i=0; i<foreign_keys.size(); i++ ){
        foreign_key_relationship this_relationship(
            foreign_keys[i]["parent_table"].c_str(),
            foreign_keys[i]["parent_column"].c_str(),
            foreign_keys[i]["child_table"].c_str(),
            foreign_keys[i]["child_column"].c_str()
        );
        if( !table_edges.count( this_relationship ) && tables_to_connect.count( foreign_keys[i]["parent_table"].c_str() ) && tables_to_connect.count( foreign_keys[i]["child_table"].c_str() ) ){
            table_edges[ this_relationship ] = boost::add_edge(
                table_vertices[ string( foreign_keys[i]["parent_table"].c_str() ) ], 
                table_vertices[ string( foreign_keys[i]["child_table"].c_str() ) ], 
                this_relationship, 
                rg
            ).first;
            ds.union_set( table_vertices[ string( foreign_keys[i]["parent_table"].c_str() ) ], table_vertices[ string( foreign_keys[i]["child_table"].c_str() ) ] );
        }
    }
}

void add_possible_linking_vertex( result &foreign_keys, map< string, relational_vertex > &table_vertices, relational_graph &rg ){
    for( unsigned i=0; i<foreign_keys.size(); i++ ){
        if( !table_vertices.count( foreign_keys[i]["parent_table"].c_str() ) ){
            table_vertices[ foreign_keys[i]["parent_table"].c_str() ] = boost::add_vertex( foreign_keys[i]["parent_table"].c_str(), rg );
            break;
        }
        if( foreign_keys[i]["child_table"].c_str() ){
            table_vertices[ foreign_keys[i]["child_table"].c_str() ] = boost::add_vertex( foreign_keys[i]["child_table"].c_str(), rg );
            break;
        }
    }
}    

set< foreign_key_relationship > get_foreign_keys( transaction_base &t, set<string> tables_to_connect ){
    try{
        result foreign_keys = t.prepared("get_foreign_keys").exec();

        set< foreign_key_relationship > relational_routes;

        if( tables_to_connect.size() ){

            relational_graph rg;

            map< string, relational_vertex > table_vertices;
            for( string table: tables_to_connect )
                table_vertices[ table ] = boost::add_vertex( table, rg );

            std::vector<relational_vertex_index> rank( num_vertices(rg) );
            std::vector<relational_vertex> parent( num_vertices(rg) );

            boost::disjoint_sets<relational_rank, relational_parent> ds(&rank[0], &parent[0]);

            boost::initialize_incremental_components(rg, ds);
            boost::incremental_components(rg, ds);

            map< foreign_key_relationship, relational_edge > table_edges;
            for( unsigned i=0; i<foreign_keys.size(); i++ )
                connect_relational_vertices( table_edges, foreign_keys, tables_to_connect, table_vertices, rg, ds );

        }

        return relational_routes;
    }
    catch( const pqxx_exception &e ){
        libpqxx_error( e );
        set< foreign_key_relationship > relational_routes;
        return relational_routes;
    }
}

int main()
{
    relational_graph rg;
    map<foreign_key_relationship, relational_edge> table_edges;
    pqxx::result data;
    set<string> tables { "foo", "bar" };
    map<string, relational_vertex> table_vertices;
    boost::disjoint_sets<relational_rank, relational_parent> ds(relational_rank{}, relational_parent{});

    connect_relational_vertices(table_edges, data, tables, table_vertices, rg, ds);
}

I compiled with 我用

  • gcc 4.8, 4.9, clang 3.5-1 gcc 4.8、4.9,clang 3.5-1
  • boost 1_56_0 提高1_56_0
  • command line: 命令行:

    g++ -std=c++0x -Wall -pedantic -lpthread -g -O0 -isystem ~/custom/boost/ -isystem /usr/include/mpi test.cpp -o test -lmpich -lpqxx g ++ -std = c ++ 0x -Wall -pedantic -lpthread -g -O0 -isystem〜/ custom / boost / -isystem / usr / include / mpi test.cpp -o test -lmpich -lpqxx

不匹配调用 '(const Y) (int&amp;, std::mersenne_twister_engine <long unsigned int,< div><div id="text_translate"><p> 有我的.hpp:</p><pre> #include &lt;random&gt; #include &lt;ctime&gt; #include &lt;cmath&gt; #ifndef RECUIT_HPP #define RECUIT_HPP template &lt; class E, class Func, class TempSeq, class RandomY, class RNG&gt; E recuit_simule(const Func &amp; phi, E x0, const TempSeq &amp; T, const RandomY &amp; Y, RNG &amp; G, long unsigned N) { std::uniform_real_distribution&lt;double&gt; U(0,1); E y; double u; for(int i=0; i&lt;N; i++) { y=Y(x0, G); u=U(G); if(u &lt;= fmin(1, exp((phi(x0) - phi(y))/T(N)))) { x0=y; } } return x0; } #endif</pre><p> 和我的.cpp:</p><pre> #include "recuit.hpp" #include &lt;iostream&gt; class Y { private: std::normal_distribution&lt;double&gt; N; public: Y(): N(0,1) {} double operator()(const double &amp; x, std::mt19937 &amp; G) { return x + N(G); } }; int main() { auto phi=[](const double &amp; x) { return x*x*x*x*x*x - 48*x*x; }; auto T=[] (long unsigned n) { return 10 * pow(0.9, n); }; YA; std::mt19937 G; double x = recuit_simule(phi, 0, T, A, G, 1000); std::cout &lt;&lt; x &lt;&lt; std::endl; return 0; }</pre><p> 当我编译 my.cpp 时,my.hpp 中有以下错误:</p><blockquote><p> recuit.hpp:17:6: 错误: 不匹配调用 '(const Y) (int&amp;, std::mersenne_twister_engine&amp;)'</p></blockquote><p> 对于该行:</p><pre> y=Y(x0, G);</pre><p> 我不明白为什么</p></div></long> - no match for call to ‘(const Y) (int&, std::mersenne_twister_engine<long unsigned int,

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:没有匹配的 function 调用 'min(long unsigned int&, unsigned int&)' - error: no matching function for call to ‘min(long unsigned int&, unsigned int&)’ 没有从long unsigned int转换为long unsigned int& - No conversion from long unsigned int to long unsigned int& unsigned long long int - unsigned long long int 不匹配调用 '(const Y) (int&amp;, std::mersenne_twister_engine <long unsigned int,< div><div id="text_translate"><p> 有我的.hpp:</p><pre> #include &lt;random&gt; #include &lt;ctime&gt; #include &lt;cmath&gt; #ifndef RECUIT_HPP #define RECUIT_HPP template &lt; class E, class Func, class TempSeq, class RandomY, class RNG&gt; E recuit_simule(const Func &amp; phi, E x0, const TempSeq &amp; T, const RandomY &amp; Y, RNG &amp; G, long unsigned N) { std::uniform_real_distribution&lt;double&gt; U(0,1); E y; double u; for(int i=0; i&lt;N; i++) { y=Y(x0, G); u=U(G); if(u &lt;= fmin(1, exp((phi(x0) - phi(y))/T(N)))) { x0=y; } } return x0; } #endif</pre><p> 和我的.cpp:</p><pre> #include "recuit.hpp" #include &lt;iostream&gt; class Y { private: std::normal_distribution&lt;double&gt; N; public: Y(): N(0,1) {} double operator()(const double &amp; x, std::mt19937 &amp; G) { return x + N(G); } }; int main() { auto phi=[](const double &amp; x) { return x*x*x*x*x*x - 48*x*x; }; auto T=[] (long unsigned n) { return 10 * pow(0.9, n); }; YA; std::mt19937 G; double x = recuit_simule(phi, 0, T, A, G, 1000); std::cout &lt;&lt; x &lt;&lt; std::endl; return 0; }</pre><p> 当我编译 my.cpp 时,my.hpp 中有以下错误:</p><blockquote><p> recuit.hpp:17:6: 错误: 不匹配调用 '(const Y) (int&amp;, std::mersenne_twister_engine&amp;)'</p></blockquote><p> 对于该行:</p><pre> y=Y(x0, G);</pre><p> 我不明白为什么</p></div></long> - no match for call to ‘(const Y) (int&, std::mersenne_twister_engine<long unsigned int, 没有匹配呼叫&#39;(std :: pair <unsigned int, unsigned int> )(unsigned int&,unsigned int)&#39; - No match for call to '(std::pair<unsigned int, unsigned int>) (unsigned int&, unsigned int)' 将int转换为unsigned long long - casting int to unsigned long long boost :: transitive_closure()和“错误:没有匹配的函数来调用&#39;vertices(const std :: vector <std::vector<long unsigned int> ……” - boost::transitive_closure() and “error: no matching function for call to ‘vertices(const std::vector<std::vector<long unsigned int>…” unsigned int to unsigned long long well defined? - Unsigned int to unsigned long long well defined? “ unsigned long int”和“ unsigned long long int”分配问题 - 'unsigned long int', and 'unsigned long long int' assignment issue 无符号长整型VS无符号长整型int - unsigned long long VS unsigned long long int
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM