小编Ser*_*e C的帖子

通过键查找Boost BGL顶点

我正在寻找一种通过使用键而不是顶点引用本身来访问顶点属性的方法.例如,如果我有

class Data
{
  public:
    std::string  name;
    unsigned int value; 
}; 
typedef boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS, Data > Graph;
typedef boost::graph_traits<Graph>::vertex_descriptor Vertex;
Run Code Online (Sandbox Code Playgroud)

而不是使用

Vertex vertex1 = boost::add_vertex( g );
g[vertex1].name  = "Alpha";
g[vertex1].value = 10;
Run Code Online (Sandbox Code Playgroud)

我想拥有

g["Alpha"].name  = "Alpha";
g["Alpha"].value = 10;
Run Code Online (Sandbox Code Playgroud)

是否存在现成的机制?

c++ boost graph boost-graph

32
推荐指数
1
解决办法
8491
查看次数

用面具搜索

有大量条目具有以下类型:

typedef struct {
    int value;
    int mask;
    int otherData;
} Entry;
Run Code Online (Sandbox Code Playgroud)

我想根据提供的int key;速度尽可能快地在这个数组中找到一个条目.该条目是确保这一点(key & mask) == value.

这种阵列组织的最佳方法是什么,处理它的相应算法是什么?

编辑:阵列组织没有限制; 它是静态的,可以在查找之前准备好.该valuemask可以有任意值.

Edit2:value并且mask可以具有任意值,但是数组中的条目数约为10000.因此,可以预先计算某些"paterns".

查找次数很多.

c c++ algorithm search mask

10
推荐指数
1
解决办法
1075
查看次数

Boost.Test应用程序调试

在VS2010(VS2008)中调试C++ Boost.Test应用程序时,如何使调试器停止在Boost.Test断言失败点?

c++ boost unit-testing visual-studio-2010

6
推荐指数
1
解决办法
1872
查看次数

用于VLIW体系结构的GCC编译器基础结构

您知道GCC编译器基础架构中存在多大的VLIW架构支持吗?我知道GCC支持一些VLIW架构.看看它们,似乎管道优化留给了另一个优化层.这是否有好的(不是GCC内部文件)材料?

compiler-construction gcc cross-platform vliw

5
推荐指数
1
解决办法
832
查看次数

GCC的软件流水线示例

我正在寻找由GCC制作的软件流水线(http://en.wikipedia.org/wiki/Software_pipelining)的真实(源代码和生成代码)示例.我-fmodulo-sched在GCC版本4.4-4.6编译IA64和PowerPC架构时尝试使用选项但没有成功.你知道这样的例子吗?实际的CPU架构没有区别.

谢谢

c compiler-construction gcc

5
推荐指数
1
解决办法
1259
查看次数

"错误:使用std :: string时不匹配'operator <<"

你可以帮我找到下面代码中的问题(代码类似于C++流作为重载operator <<时的参数):

#include <iostream>
#include <string>

class logger
{
  public:
    void init( std::ostream& ostr )
    {
        stream = &ostr;
    }

    template< typename t >
    logger& operator <<( t& data )
    {
        *stream << data;
        return *this;
    }

    logger& operator <<( std::ostream& (*manip)(std::ostream &) )
    {
        manip( *stream );
        return *this;
    }

    logger& operator <<( std::ios_base& (*manip)(std::ios_base&) )
    {
        manip( *stream );
        return *this;
    }

  private:
    std::ostream* stream;
};

int main( int argc, char* argv[] )
{
    logger log; …
Run Code Online (Sandbox Code Playgroud)

c++ string iostream

5
推荐指数
1
解决办法
2106
查看次数

Windows和*nix编译检测

应该为Windows,Linux和嵌入式目标编译一个项目.在主机或嵌入式目标上运行时,应用程序具有行为差异.总结我的要求,这是表:

   Target               Compiler      Behavior
   Windows              MSVC, gcc         A
   Host Linux           gcc               A
   Embedded Linux       cross pltf gcc    B
Run Code Online (Sandbox Code Playgroud)

我希望创建一个自动识别编译器和环境差异的Makefile(无需手动传递参数/定义).是否可以通过在C源文件级别使用条件编译来解决此类问题?
到目前为止我还没有使用automake.

c linux windows makefile embedded-linux

2
推荐指数
1
解决办法
1589
查看次数