带有std :: functional的clang(XCode 5.0.2)错误,它有三个以上的参数 [英] Error on clang (XCode 5.0.2) with std::functional that has more than three parameter

查看:336
本文介绍了带有std :: functional的clang(XCode 5.0.2)错误,它有三个以上的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,考虑clang的行为与c ++ std ::功能实现。首先,首先:这里是一些代码,我试图编译下MacOS小牛与XCode 5.0.2

  #include <功能> 
#include< ostream>

typedef std :: function< std :: ostream& (const void *,std :: ostream& uint32_t& bool)> my_fancy_functor;

static void doSomething(const my_fancy_functor fcn)
{
// ... do something
}
pre>

这会导致含有以下文本的语义错误:

 未定义模板的隐式实例化'std :: __ 1 :: function< std :: __ 1 :: basic_ostream< char> &(const void *,std :: __ 1 :: basic_ostream< char>& unsigned int& bool *)>'

将typedef更改为只有三个参数的std ::函数只会编译很好

  typedef std :: function< std :: ostream& (const void *,std :: ostream& uint32_t&)> my_fancy_functor; 

有人知道我在这里做错了。该代码编译精细与Visual Studio 2010-2013以及gcc版本> 4.7.0



到目前为止,我相信它与std无关:: ostream用在里面的功能。用任何其他可想象的类型替换此示例中使用的任何类型将导致只有相同的错误消息,这让我相信std :: functional本身的实现可能有问题。



任何可以帮助我解决这个问题的帮助或提示都将非常感激。

解决方案

C ++语言方言设置为 C ++ 11 [-std = c ++ 11] 中的 GNU ++ 11 [-std = gnu ++ 11] 罚款。


I'm stuck with a problem considering clang's behavior with c++ std::functional implementation. Well first things first: Here is some code that I'm trying to compile under MacOs Mavericks with XCode 5.0.2

#include <functional>
#include <ostream>

typedef std::function< std::ostream& (const void*, std::ostream&, uint32_t&, bool) > my_fancy_functor;

static void doSomething(const my_fancy_functor fcn)
{
   //... do something
}    

This results in a "Semantic Error" that holds the following text:

Implicit instantiation of undefined template 'std::__1::function<std::__1::basic_ostream<char> &(const void *, std::__1::basic_ostream<char> &, unsigned int &, bool *)>'

changing the typedef to a std::function that only gets three parameters will compile just fine

typedef std::function< std::ostream& (const void*, std::ostream&, uint32_t&) > my_fancy_functor;

Has anyone an idea what I'm doing wrong here. The code compiles fine with Visual Studio 2010-2013 as well as with gcc version > 4.7.0

As of now I'm sure it has nothing to do with the std::ostream used inside the functional. Substituting any of the types used inside this example with any other imaginable type will result in just the same error message, which brings me to believing that there could be something wrong with the implementation of the std::functional itself.

Any help or hint which helps me resolving this mess will be much appreciated!

解决方案

Set the C++ Language Dialect to C++11 [-std=c++11] or GNU++11 [-std=gnu++11] in your Build Settings and it's going to compile just fine.

这篇关于带有std :: functional的clang(XCode 5.0.2)错误,它有三个以上的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆