Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
9
votes
Accepted
Create C++14 library where each class has 2 similar variants
One possible solution is to use templates and move the CPU / GPU specific stuff into a traits class:
struct CPUBackendTraits {
template <typename T>
using vector_type = std::vector<T>;
};
struct … All code is in templates, so if you want to use .cpp files for that code, you must add explicit template instantiations. …
13
votes
Accepted
C++ Preferred method of dealing with implementation for large templates
When writing a templated C++ class, you usually have three options:
(1) Put declaration and definition in the header.
// foo.h
#pragma once
template <typename T>
struct Foo
{
void f()
{
…
7
votes
Accepted
C++ design pattern for template instantiation based on run time information?
For example, if you want to instantiate the templates for a fixed list of integers, you can do the following:
template <int N, int... …