gpt4 book ai didi

c++ - FC++ 是否适用于 g++ 4.5.0?

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:59:28 24 4
gpt4 key购买 nike

FC++ 是一个用于 C++ 函数式编程的库。我在带有 gcc 4.5.0 的 MinGW 上使用它。当我使用更基本的功能时,我没有任何问题。但是更高级的功能之一是给我一个与模板相关的错误(或者可能只是我的代码有问题......不可能!)。

是否有人使用 4.5.0 的 FC++?看到我的代码有什么问题吗?

link text已经过时了,尽管它显示了 gcc 和模板特化问题的历史。 link text不是最新的。

这是我的代码:

#include <iostream>
#include "prelude.h"

using namespace fcpp;
using namespace std;

struct TwoTimes {
template <class T>
struct Sig : public FunType<T,T> {};

template <class F>
F operator() (const F& x) const { return 2*x; };
} twoTimes;


int main(int argc, char* argv[] )
{
cout << compose(twoTimes,twoTimes)(3) << endl;
return 0;
}

我得到的错误是:

In file included from full.h:14:0,
from lambda.h:38,
from operator.h:29,
from function.h:23,
from reuse.h:14,
from list.h:31,
from prelude.h:32,
from y.cxx:2:
smart.h: In instantiation of 'fcpp::FunctoidTraits<TwoTimes>':
prelude.h:142:74: instantiated from 'fcpp::impl::XCompose::Sig<TwoTimes, TwoTimes>'
full.h:94:53: instantiated from 'fcpp::Full2<fcpp::impl::XCompose>::Sig<TwoTimes, TwoTimes>'
y.cxx:18:46: instantiated from here
smart.h:103:7: error: no type named 'Type' in 'struct
fcpp::impl::NeededASmartFunctoidButInsteadGot<TwoTimes, false>'
In file included from y.cxx:2:0:
prelude.h: In instantiation of 'fcpp::impl::XCompose::Sig<TwoTimes, TwoTimes>':
full.h:94:53: instantiated from 'fcpp::Full2<fcpp::impl::XCompose>::Sig<TwoTimes, TwoTimes>'
y.cxx:18:46: instantiated from here
prelude.h:142:74: error: 'fcpp::FunctoidTraits<TwoTimes>::max_args' is not a valid
template argument for type 'int' because it is a non-constant expression
In file included from lambda.h:38:0,
from operator.h:29,
from function.h:23,
from reuse.h:14,
from list.h:31,
from prelude.h:32,
from y.cxx:2:
full.h: In instantiation of 'fcpp::Full2<fcpp::impl::XCompose>::Sig<TwoTimes, TwoTimes>':
y.cxx:18:46:
instantiated from here
full.h:94:53: error: no type named 'Arg1Type' in 'struct
fcpp::impl::XCompose::Sig<TwoTimes, TwoTimes>'
y.cxx: In function 'int main(int, char**)':
y.cxx:18:46: error: no match for call to '(fcpp::Compose) (TwoTimes&, TwoTimes&)'

最佳答案

嗯……您提到的链接已有七年历史了。在狗年和编译器时代,那是美好的一生。

如果您想要使用(当前)C++ 编译器进行函数式编程,可能是 Boost 中的一些可能对图书馆感兴趣?

关于c++ - FC++ 是否适用于 g++ 4.5.0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4564636/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com