小编Sla*_*lav的帖子

平台OpenCL版本和设备有什么不同?

具体来说,我有单平台版本2.1和单设备版本2.0,我想使用仅在OpenCL 2.1中支持的C++14功能。我应该可以吗?当涉及到能力限制时,什么最重要:平台还是设备?既然平台版本总是归结为使用设备,那么平台版本还有什么意义呢?

opencl

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

如何有条件地编写依赖于 C++ 中 lambda 返回类型的代码?

我有为它迭代的每个元素调用回调的函数:

#include <type_traits>
#include <iostream>
using namespace std;

void iterate( const auto & on_element ) {
    for ( int i = 0; i < 10; ++ i ) {
        //here I want to stop iteration if function returns bool true:
        if constexpr ( is_same< result_of( on_element )::type, bool >::value )
            if ( ! on_element( i ) )
                return;
        //but when callback doesn't return bool - simply iterate the whole range:
        else
            on_element( i );
    }
}

int main() {
    const …
Run Code Online (Sandbox Code Playgroud)

c++ templates std

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

为什么 C++ 假装忘记以前解析过的模板?

这是使用以下命令编译的数据序列化程序gcc 11.1

#include <fstream>
#include <ranges>
#include <concepts>
#include <map>
using namespace std;

void write( fstream & f, const integral auto & data ) {
    f.write( (const char*)&data, sizeof( data ) );
}

void write( fstream & f, const pair<auto,auto> & p ) {
    write( f, p.first );
    write( f, p.second );
}

template< ranges::range T >
void write( fstream & f, const T & data ) {
    const uint64_t size = ranges::size( data );
    write( f, size …
Run Code Online (Sandbox Code Playgroud)

c++ gcc templates c++20

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

启动没有线程实例名称的线程

有什么区别

MyClass* myClass = new MyClass;
std::thread myThread( &MyClass::MyMemberFunction, myClass );
Run Code Online (Sandbox Code Playgroud)

std::thread( &MyClass::MyMemberFunction, myClass );
Run Code Online (Sandbox Code Playgroud)

PS尝试使用第二种方法将boost :: asio :: io_service放入单独的线程 - 不起作用.但第一个确实如此.如果改变std提升,两种方法都有效.

WIndows 7. MSVS 12.0.

c++ multithreading boost std

0
推荐指数
1
解决办法
189
查看次数

标签 统计

c++ ×3

std ×2

templates ×2

boost ×1

c++20 ×1

gcc ×1

multithreading ×1

opencl ×1