问题列表 - 第21093页

如何从另一个命名空间中的全局命名空间定义友元类?

在之前的问答(如何在另一个 C++ 命名空间中定义全局命名空间中的友元?)中,给出了在引用全局命名空间中的函数的命名空间内定义友元函数的解决方案。

我对classes有同样的问题。

class CBaseSD;

namespace cb {
class CBase
{
    friend class ::CBaseSD; // <-- this does not work!?
private:
    int m_type;
public:
    CBase(int t) : m_type(t) {};
};
}; // namespace cb

class CBaseSD
{
private:
    cb::CBase*  m_base;
public:
    CBaseSD(cb::CBase* base) : m_base(base) {};
    int* getTypePtr()
    { return &(m_base->m_type); };
};
Run Code Online (Sandbox Code Playgroud)

如果我将 CBaseSD 放入命名空间,它就可以工作;例如,朋友类 SD::CBaseSD;但我还没有找到适用于全局命名空间的咒语。

我正在使用 g++ 4.1.2 进行编译。

c++ namespaces global friend

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

git拒绝获取当前分支

我设置了一个远程存储库,我可以对它进行新的更改,但我无法从中获取,我总是得到(相当神秘的)错误消息:

fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

这是什么意思?我该怎么做才能获取?

(请注意,此远程仓库仅用作备份仓库,因此它应该是我本地存储库的精确副本.我真的无法理解为什么我可以推送它但不能从中获取...)

我的配置看起来像:

[remote "origin"]
    url = ssh://blablablah
    fetch = +refs/*:refs/*
    mirror = true
Run Code Online (Sandbox Code Playgroud)

git git-fetch

59
推荐指数
4
解决办法
4万
查看次数

580
推荐指数
10
解决办法
34万
查看次数

发送信号到valgrind内的进程?

如何向在valgrind内部运行的进程发送信号以检查其内存使用状态?

谢谢!

valgrind memory-leaks

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

Firefox或JavaScript,统计DOM

我确信这很简单,但我不知道该怎么做.我如何计算HTML页面中DOM元素的数量?我想在用户脚本或书签中这样做,但我不知道如何开始!

javascript firefox dom bookmarklet userscripts

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

Quartz.net和Common.Logging - 使用Log4Net

我在Windows服务中使用Quartz.net.目前,触发器没有触发 - 我想使用日志记录找出原因.

我编辑了Windows服务的配置文件:

<configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

    <sectionGroup name="common">
      <section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
    </sectionGroup>
</configSections>

<appSettings>
    <!--specific win service settings here-->
</appSettings>

<common>
    <logging>
        <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net">
            <arg key="configType" value="INLINE"/>
            <arg key="configFile" value="c:\sched.log"/>
            <arg key="level" value="INFO" />
        </factoryAdapter>
    </logging>
</common>

<log4net>
    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%d [%t] %-5p %l - %m%n" />
      </layout>
    </appender>
    <root>
      <level value="INFO" />
      <appender-ref ref="EventLogAppender" />
    </root>
</log4net>
Run Code Online (Sandbox Code Playgroud)

我的文件结构如下:

C:\ CompanyName - 所有项目的根目录
C:\ CompanyName\build\bin - 我的解决方案中所有项目/类库的输出目录
C:\ CompanyName\lib …

c# logging log4net quartz.net common.logging

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

高效查询多分区Postgres表

我刚刚重构了我的数据库,以便在Postgres 8.2中使用分区.现在我的查询性能有问题:

SELECT *
FROM my_table
WHERE time_stamp >= '2010-02-10' and time_stamp < '2010-02-11'
ORDER BY id DESC
LIMIT 100;
Run Code Online (Sandbox Code Playgroud)

表中有4500万行.在分区之前,这将使用反向索引扫描并在达到限制时立即停止.

分区后(在time_stamp范围内),Postgres对主表和相关分区进行完整索引扫描并合并结果,对它们进行排序,然后应用限制.这需要太长时间.

我可以解决它:

SELECT * FROM (
  SELECT *
  FROM my_table_part_a
  WHERE time_stamp >= '2010-02-10' and time_stamp < '2010-02-11'
  ORDER BY id DESC
  LIMIT 100) t
UNION ALL
SELECT * FROM (
  SELECT *
  FROM my_table_part_b
  WHERE time_stamp >= '2010-02-10' and time_stamp < '2010-02-11'
  ORDER BY id DESC
  LIMIT 100) t
UNION ALL
  ... and so on ... …
Run Code Online (Sandbox Code Playgroud)

sql postgresql performance partitioning

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

Emacs云存储选项?

在Emacs中,有哪些选项可以保存和从云中检索文档?

我在工作中,在Windows机器上,在家里,在Linux机器上使用Emacs,所以理想情况下我想要一个对于两个操作系统都或多或少开箱即用的解决方案.

我触及了g-client,但却无法完成它.显然,如果没有其他更简单的选择,我将不得不花费更多时间.

非常感谢,Andreas

cloud emacs data-storage

6
推荐指数
2
解决办法
2330
查看次数

更改.Net中序列化的类的名称?

我可以通过使用SerializationBinder和覆盖BindToType方法来映射传入的类名,但我发现无法在序列化过程中更改类的名称.有可能吗?

编辑:

我指的是使用的序列化System.Runtime.Serialization,而不是System.Xml.Serialization.

谢谢!

.net c# serialization

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

CSS问题:"text-align:center"和"min-width"的组合在IE 7/IE 8 compat模式下不起作用

这是我的HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">
    input.navbutton
    {
        text-align: center;
        min-width: 100px;
    }
</style>
</head>
<body>
    <input type="submit" class="navbutton " value="Next" />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

在IE 7上,这最终看起来像这样:

替代文字

但在Firefox上它看起来像这样:

替代文字

如您所见,文本未在IE 7中正确居中.

关于如何解决这个问题的任何想法?

css internet-explorer

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