Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
62 views

Given a template T and some type U, I can write a trait to see if U is an instantiation of T. For a simple case of a single template argument the trait could look like this: #include <type_traits&...
463035818_is_not_an_ai's user avatar
0 votes
0 answers
25 views

I have built a template project with a Template.json and this will generate the template fine ( no errors at all ) ive also managed to add some choices to the symbols that will add or hide code ...
Bithellio's user avatar
7 votes
1 answer
210 views

Suppose the following foo function has a function parameter and a template parameter, both with the same default value: template<int Line=std::source_location::current().line()> auto foo (int ...
abcdefg's user avatar
  • 4,442
Best practices
0 votes
3 replies
90 views

I'm struggling to finalise the design of my C++17 library. One of the primary goals is to use runtime polymorphism to allow users to extend or rewrite default features of the library for their own use ...
josh_eime's user avatar
  • 176
0 votes
1 answer
36 views

I’m using the WooCommerce PDF Invoices & Packing Slips plugin by WP Overnight. I’ve successfully: Created a second custom PDF template (a voucher version without prices). Added a button on the ...
Mina's user avatar
  • 303
1 vote
0 answers
122 views

I'm confused by how C++ handles static member access in templates when inheritance and dependent names are involved. Look at this code: struct Global { static int value; }; template<typename T&...
Dipak Halkude's user avatar
17 votes
3 answers
874 views

I have a function template f, defining in its body a local class A with another nested class B. Both classes are not templates. Must I name the inner class as typename A::B or shorter variant A::B is ...
Fedor's user avatar
  • 24.7k
-1 votes
1 answer
66 views

I'm tasked with implementing a custom DataGrid-like control in one of my projects. This is due to many specific features it needs to have implemented, and also the large amounts of data that have to ...
Qrakhen's user avatar
  • 115
2 votes
1 answer
87 views

I am creating my first template for a .NET solution. For the most part it works, but I have a string "MyService" at some places in the Program.cs that I would like to replace with "...
Myrkjartan's user avatar
6 votes
2 answers
315 views

I've got many templated classes which all need to be explicitly instantiated on the same set of parameters e.g. template class A<double, size_t>; template class A<double, unsigned int>; ...
Otto von Bisquick's user avatar
8 votes
6 answers
852 views

If it's possible, I would like to define a macro that would take number of arguments in function template ARGS_COUNT and make a template with all argument types being enumerated and output being ...
kusok_kvarka's user avatar
4 votes
2 answers
175 views

I have several structs in the form struct MyStruct1 { std::string myName; // ... } but not all of them have a member of type std::string and variable named myName. I'm writing a function template,...
RocketSearcher's user avatar
-1 votes
2 answers
85 views

I want to use gorazor a viewengine written in go that uses razor-Syntax. They provide an example which i tried to understand and adapt. What is working I want to iterate over a slices of movies and ...
surfmuggle's user avatar
  • 6,040
2 votes
2 answers
195 views

I'm making it using multi inheritance with a pair struct that contains an index and the type of the element in a recursive structure like this: template<int index, typename... ts> struct ok; ...
thefentmaster5's user avatar
0 votes
0 answers
135 views

In Visual Studio 2026 Insiders, while right clicking on my xUnit Test Project, and clicking to add a new file, I found this weird item template at the bottom which does not appear to be visible in ...
winscripter's user avatar
1 vote
2 answers
96 views

SONAR's cpp:S5213 rule says that Template parameters should be preferred to "std::function" when configuring behavior at compile time We have tried implementing that by replacing std::...
bers's user avatar
  • 6,299
0 votes
0 answers
27 views

I'm working on an Express + EJS project and getting this error when rendering my invoice.ejs view: TypeError: C:\Users\naray\OneDrive\Desktop\Invoice-saas\invoice-generator\views\invoice.ejs:17 >&...
Narayan's user avatar
2 votes
1 answer
185 views

I'm using some templates in my project. I prefer the approach of putting the declarations in a .h file and the definitions in a .tpp file. Currently it's set up like this: // myclass.h class myClass { ...
bur's user avatar
  • 899
6 votes
2 answers
182 views

I'd like to enforce a CRTP template parameter to be an actual derived type. Unfortunately it seems to be impossible to express that as a constraint. The problem is that the constrained type is ...
Bernd's user avatar
  • 2,471
1 vote
1 answer
108 views

I am using the following code for automatic vector/matrix template parameter deduction (I am particullarily interested in automatic deduction from passing initializer lists) template<class T, ...
Xenos's user avatar
  • 223
5 votes
2 answers
262 views

I am working in a codebase that makes heavy use of templates. This causes many issues with debugging, because the compiler leaves almost no debugging information behind to tie object code back to ...
nispio's user avatar
  • 1,806
1 vote
1 answer
154 views

struct ResultDeleter { typedef HANDLE pointer; void operator()(pointer ptr) noexcept { ResultFree(ptr); } }; template<typename P = std::unique_ptr<std::remove_pointer_t&...
ebmoluoc's user avatar
0 votes
0 answers
89 views

Here's the minimal example for the issue I'm trying to solve #include <iostream> template<class F_TYPE, F_TYPE F, class T> auto func(const T &value) { return F(value); } template&...
Phil Rosenberg's user avatar
10 votes
0 answers
176 views

MSVC doesn't accept this code, even the latest version on Godbolt: #include <type_traits> template <class R> struct A { A(); }; template <class R> requires std::is_reference_v&...
Brian Bi's user avatar
  • 123k
5 votes
1 answer
147 views

In the C++20 draft (N4868) there are two relevant rules about definition reachability: Inline functions must have their definition reachable in every translation unit in which they are ODR-used: [...
klezki's user avatar
  • 197

1
2 3 4 5
1115