Skip to content

Conversation

@GeLee-Q
Copy link

@GeLee-Q GeLee-Q commented Feb 4, 2022

写一下在MSVC编译器下做这个实验室tips

1.开启OpenMP

  • 可以直接使用Visual Studio,应该是内部集成了;
  • Clion+MSVC暂时不知道怎么开启;

2. alignalloc.h中的问题

  • aligned_alloc 并未被MSVC支持,但改用其 _aligned_malloc即可;

3.ndarray.h中模板元编程出Bug

    // template <class ...Ts, std::enable_if_t<sizeof...(Ts) == N && (std::is_integral_v<Ts> && ...), int> = 0>

    template <class ...Ts, std::enable_if_t<sizeof...(Ts) == N && std::conjunction_v<std::is_integral<Ts>...> , int> = 0>

如果不这样更改,会始终报编译器错误 C2059

参考解决方案:
/compiler-error-with-a-fold-expression-in-enable-if-t)

@archibate
Copy link
Contributor

你是VS2017吗?似乎是不支持cpp17导致的,课程要求使用VS2019。

@GeLee-Q
Copy link
Author

GeLee-Q commented Feb 6, 2022

我的是VS2019,这个bug是应该MSVC特有的问题,模板里面套 enable if再套模板用fold expression的话,msvc连parse都出错。

因为同样的代码,我切换到Mingw编译器的时候,ndarray.h便不会报这个错误,正常的运行程序。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants