Linked Questions

575 votes
34 answers
397k views

Contrary to all other similar questions, this question is about using the new C++ features. 2008 c Is there a simple way to convert C++ enum to string? 2008 c Easy way to use variables of enum types ...
oHo's user avatar
  • 55.1k
1078 votes
6 answers
362k views

It's common in C++ to name member variables with some kind of prefix to denote the fact that they're member variables, rather than local variables or parameters. If you've come from an MFC background, ...
Roger Lipscombe's user avatar
293 votes
11 answers
119k views

I'm trying to store in a std::tuple a varying number of values, which will later be used as arguments for a call to a function pointer which matches the stored types. I've created a simplified ...
Flexo - Save the data dump's user avatar
175 votes
13 answers
87k views

Consider the case of a templated function with variadic template arguments: template<typename Tret, typename... T> Tret func(const T&... t); Now, I have a tuple t of values. How do I call ...
user avatar
119 votes
12 answers
72k views

I have read in few different places that using C++11's new string literals it might be possible to compute a string's hash at compile time. However, no one seems to be ready to come out and say that ...
deft_code's user avatar
  • 59.8k
79 votes
8 answers
165k views

Can C-Style strings be used as template arguments? I tried: template <char *str> struct X { const char *GetString() const { return str; } }; int main() { X<"String"...
cvb's user avatar
  • 4,609
41 votes
8 answers
19k views

I've written a variadic template that accepts a variable number of char parameters, i.e. template <char... Chars> struct Foo; I was just wondering if there were any macro tricks that would ...
Peter Alexander's user avatar
35 votes
3 answers
26k views

I am trying to use templates to create an analogue of the type_info::name() function which emits the const-qualified name. E.g. typeid(bool const).name() is "bool" but I want to see "bool const". So ...
George Skelton's user avatar
17 votes
5 answers
17k views

Is it possible to concat two string literals using a constexpr? Or put differently, can one eliminate macros in code like: #define nl(str) str "\n" int main() { std::cout << nl("usage: ...
Micha Wiedenmann's user avatar
12 votes
4 answers
28k views

Looks like I can init a POD static const member, but not other types: struct C { static const int a = 42; // OK static const string b = "hi"; // compile error }; Why?
Deqing's user avatar
  • 14.8k
28 votes
1 answer
4k views

Many developers and library authors have been struggling with compile-time strings for quite a few years now - as the standard (library) string, std::string, requires dynamic memory allocation, and ...
einpoklum's user avatar
  • 137k
18 votes
2 answers
10k views

I want to have a compile-time string encryption, such that I could write in my code: const auto encryptedInvalidLicense = ENCRYPT("Invalid license"); std::cout << encryptedInvalidLicense....
Curve25519's user avatar
16 votes
1 answer
5k views

Sorry that this will be a long post, but I feel like you need all of the code to see what's going on. So, I have been experimenting with an idea for compile time string to data structure parser. Think ...
Evan Teran's user avatar
  • 90.9k
4 votes
2 answers
4k views

Let's take a simple SFINAE templating example #include <iostream> template <typename T> struct has_typedef_foobar { // Types "yes" and "no" are guaranteed to have different sizes, ...
user avatar
6 votes
4 answers
10k views

Currently I have: template <typename T> struct typename_struct<T*> { static char const* name() { return (std::string(typename_struct<T>::name()) + "*").c_str(); } ...
Steven Lu's user avatar
  • 44k

15 30 50 per page