小编Kir*_*sky的帖子

VC++是否支持_mm_malloc?

Visual Studio C++ 2008/2010是否_mm_malloc正式支持?它已定义,malloc.h但我无法在MSDN库中找到它的描述.

c++ memory-management memory-alignment visual-c++

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

图DB模式的最佳点/ GraphViz布局

我第一次使用dot + GraphViz来帮助规划图表数据库架构.

随着我添加更多节点,输出看起来不太理想.特别是,语言和国家看起来相当混乱.

我已经尝试了一些基本的排名,但却无法影响它.

我怎样才能获得更清晰的输出?

代码:

digraph ReferenceGraph {
  nodesep = 2;
  edge [color=gray50, fontname=Calibri, fontsize=11]
  node [shape=record, fontname=Calibri, fontsize=11]

  root [label="Reference Node", color=darkgreen, fontcolor=darkgreen, fontname=Calibri, fontsize=11]

  sue [label="{{User}|{GivenName=Sue}|{FamilyName=Williams}|{Username=swilliams}|{EmailAddress=Sue.Williams@foo.com}|{BusinessPhone=02 1234 5678}|{MobilePhone=0414 123 456}|{PasswordSalt=fcd376dc}|{PasswordHash=a8635cfd2930ebc0cc78}|{PreviousPasswordSalt=gggf6dc}|{PreviousPasswordHash=wer435cfd2930ebc0cc78}|{RequirePasswordChangeOnNextLogin=true}|FailedLoginAttempts=0|LastLoginAttemptUtc=21 Jun 2011 16:43:01 UTC|{DateCreatedUtc=20 Jun 2011 15:43:07 UTC}}", color=blue, fontcolor=blue]
  sue -> root [label="ADMINISTERS"]

  clint [label="{{Client}|{UniqueId=100}|{GivenName=Clint}|{MiddleNames=ian bill}|{FamilyName=Wood}|{PreferredName=Woods}|{Gender=Male Female Unknown}|{PlaceOfBirthTown}|{PlaceOfBirthState}|{PlaceOfBirthCountry}|{Email=clint.wood@foo.com}|{LanguageComments}|{InterpreterRequired=true false}|{InterpreterComments}|{Religion=Buddhist}|{LegalOrders=order1}|{DateOfBirth=21 June 1979}|{DateOfBirthCertainty=Confirmed Unconfirmed Estimated}}", color=blue, fontcolor=blue]
  clint -> acme [label="CLIENT_BELONGS_TO"]
  clint -> english [label ="SPEAKS"]

  cat [label="Cat (Client)"]
  cat -> acme [label="CLIENT_BELONGS_TO"]
  cat -> english [label …
Run Code Online (Sandbox Code Playgroud)

dot graphviz graph-visualization

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

适用于C++的高质量库

我们都知道Boost.

还有哪些其他免费的C++库值得使用?为什么?它们是否可以与常见的编译器一起使用?

c++ multiplatform

5
推荐指数
2
解决办法
690
查看次数

指向const与通常指针的指针(用于函数)

指向const的指针和函数的常用指针之间有什么区别吗?什么时候使用const限定符适合独立函数?

我写了一些简短的样本来说明我的问题:

#include <iostream>
using namespace std;

int sum( int x, int y ) { return x + y; }
typedef int sum_func( int, int );

int main()
{
    const sum_func* sum_func_cptr = &sum; // const function
    sum_func* sum_func_ptr = &sum;        // non-const function ?

    // What is the difference between sum_func_cptr and sum_func_ptr

    int x = sum_func_cptr( 2, 2 );
    cout << x << endl;

    int y = sum_func_ptr( 2, 2 );
    cout << y << endl;

    sum_func_cptr = …
Run Code Online (Sandbox Code Playgroud)

c++ function-pointers

5
推荐指数
2
解决办法
3484
查看次数

如果我计划使用任意类对象作为键,我可以使用stl映射吗?

我是STL的新手.关于使用地图存储任意对象的事情让我很难过:

std::map<MyClassObj, MyDataObject> MyMap;
Run Code Online (Sandbox Code Playgroud)

是我如何找到对象.MyMap.find(MyClassObjInstance)如何工作?我是否需要实现自己的迭代器并提供一些标准函数,其中包括一些等价函数?任何例子将不胜感激.

是否有另一种方法来使用标准库存储任意对象的关联列表?我已经在使用stl来维护平台的可移植性,并且不希望像BOOST那样添加另一个库依赖项.

c++ associative-array stl

5
推荐指数
2
解决办法
1013
查看次数

如何在win32应用程序中检测显示器的热插拔?

只要有一台显示器插入系统,我就需要从Windows获得某种事件.Windows中是否有任何API可以做到这一点.顺便说一下,它是一个C++应用程序

c++ winapi monitor

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

shared_ptr与模板

如果我想创建一个指向struct的智能指针,我会这样做:

    struct A
    {
        int value;
    };
    typedef boost::shared_ptr<A> A_Ptr;
Run Code Online (Sandbox Code Playgroud)

所以,我可以写下面的内容:

    A_Ptr pA0(new A);
    pA0->value = 123;
Run Code Online (Sandbox Code Playgroud)

但是,如果我有这样的模板结构:

    template<typename T>
    struct B
    {
        T value;
    };
Run Code Online (Sandbox Code Playgroud)

我想写下面的内容:

    B_Ptr<char> pB0(new B<char>);
    pB0->value = 'w';
Run Code Online (Sandbox Code Playgroud)

那么,我该如何申报B_Ptr?

c++ templates shared-ptr

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

C++ - 函数模板专业化的目的是什么?什么时候用?

学习C++,发现了功能模板.本章提到了模板专业化.

  1. template <> void foo<int>(int);

  2. void foo( int );

为什么专注于你可以使用第二个?我认为模板可以概括.当你可以使用常规函数时,为特定数据类型专门化一个函数有什么意义?

显然,模板专业化存在是有原因的.什么时候应该使用?我读过Sutter的"为什么不专攻......"一文,但我需要更多的外行人版本,因为我只是在学习这些东西.

c++ templates

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

DHT的C++实现

我正在寻找C/C++中Kademlia DHT 的开源实现。它必须是轻量级和跨平台的(win/linux/mac)。

它必须能够将信息发布到 DHT 并检索它。

c++ cross-platform dht

5
推荐指数
2
解决办法
6638
查看次数

`shared_ptr`打破了对象的常量

请考虑以下代码:

class B 
{
    int x;
public:
    B() : x( 10 ) {}
    int get_x() const { return x; }
    void set_x( int value ) { x = value; }
};

class A
{
    boost::shared_ptr<B> b_;
public:
    boost::shared_ptr<B> get_b() const { return b_; } // (1)
};

void f( const A& a)
{
    boost::shared_ptr<B> b = a.get_b();
    int x = b->get_x();
    b->set_x( ++x ); // (2)
}

int main()
{
    A a;
    f( a );

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

在这段代码中,(2)独立编译没有任何错误或警告,这get_b …

c++ const shared-ptr c++11

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