compile-time Questions
2
Solved
The CTRE library is able to parse and validate regular expressions at compile time using syntax like ctre::match<"REGEX">(text_to_search). I know this syntax is only supported...
Ecclesiolatry asked 17/6, 2021 at 18:12
2
Solved
In C++ Weekly - Ep 313 - The constexpr Problem That Took Me 5 Years To Fix!, Jason Turner demonstrates several compile-time techniques in order to construct a std::string at compile-time and then p...
Clint asked 29/2, 2024 at 14:29
40
Solved
I am trying to move to the new build system when compiling with Xcode. However, it gives the following error:
Cycle details:
→ Target 'project' : LinkStoryboards
Target 'project' has compile comma...
Judgment asked 5/6, 2018 at 21:39
2
Is there any way to implement a custom type qualifier (similar to const)? I would like to only allow function calls to functions that are of the right qualification, within functions with the same ...
Mic asked 31/7, 2017 at 15:1
16
For now, I am using a static assert (home brewed based on other web resources) to compare the sizeof() result to various constants. While this works, it is far from elegant or fast.
I can also crea...
Seneschal asked 7/1, 2014 at 18:57
18
Solved
I'm currently trying to create a C source code which properly handles I/O whatever the endianness of the target system.
I've selected "little endian" as my I/O convention, which means that, for bi...
Niobous asked 23/1, 2012 at 21:35
3
Solved
Since it is possible that a function declared as constexpr can be called during run-time, under which criteria does the compiler decide whether to compute it at compile-time or during runtime?
te...
Hornwort asked 9/1, 2013 at 23:18
3
Is there any compile-time library (template metaprogramming) for arbitrary-precision arithmetic in C++?
I need this to help with fixed-point arithmetic and binary scaling in my program for A...
Inhaler asked 24/5, 2013 at 15:29
1
Solved
How can one choose a class template member function's argument type depending on the class template parameter value?
Here is an example:
#include <memory>
template <class T, bool plainPoin...
Phantom asked 16/11, 2023 at 20:32
8
Solved
Since the extended versions of constexpr (I think from C++14) you can declare constexpr functions that could be used as "real" constexpr. That is, the code is executed at compile time or ...
Tiber asked 24/10, 2017 at 20:37
16
Solved
How can compile-time static asserts be implemented in C (not C++), with particular emphasis on GCC?
Femi asked 2/8, 2010 at 6:32
3
Solved
I need to implement self contained compile-time function for checking type equality (function template without arguments bool eqTypes<T,S>()).
self contained means not relying on library.
I...
Aeneous asked 4/6, 2013 at 17:42
1
Solved
In the following example I would like to be told at compile time that the conversion from long to int changes the value just like I do if I don't use the user defined literal.
#include <cassert&...
Padova asked 12/1, 2023 at 12:23
4
Solved
I'd like to ensure that two interfaces are never found on the same class at compile-time, similar to how AttributeUsage checks custom Attributes at compile-time.
e.g.:
[InterfaceUsage(MutuallyExc...
Detritus asked 9/5, 2011 at 12:54
14
Solved
I'm writing some template classes for parseing some text data files, and as such it is likly the great majority of parse errors will be due to errors in the data file, which are for the most part n...
Anemography asked 28/6, 2009 at 18:30
3
Solved
I want to prevent certain functions from being called. Let's ignore the case of calling the function via a function pointer or something, and just concentrate on the case of direct function call. I...
Pochard asked 12/1, 2016 at 13:55
3
Solved
I have the following situation (live code : https://gcc.godbolt.org/z/d8jG9bs9a):
#include <iostream>
#include <type_traits>
#define ENBALE true // to enable disable test solutions
enu...
Blackthorn asked 14/8, 2022 at 21:2
2
Solved
So I've done some Google searching and this is something that has very little knowledge out there. What would be an effective and foolproof way of detecting whether X11 or Wayland is in use, prefer...
Gca asked 17/7, 2017 at 2:39
3
Solved
Let's suppose we have a template function with non-type parameter of const char * like this:
template <const char * MESSAGE> void print() {
std::cout << MESSAGE << '\n';
}
Usi...
Perithecium asked 2/3, 2015 at 12:25
2
Solved
I'm trying to make a document generation tool in angular and I'm hitting a challenge with how I would allow a user to dynamically create content.
My components I want to create could have arbitrar...
Sorcerer asked 5/10, 2017 at 1:56
1
Solved
The Raku docs describe ::?CLASS as a compile-time variable that answers "Which class am I in?". Then, a couple of paragraphs later, it mentions $?CLASS, and says that it answers "Whi...
Nidorf asked 23/2, 2022 at 18:5
1
Solved
I would like to use the fmt library to create a string_view from my format args. There is plenty documented about passing in a compile-time string as the format string, however, I want to output a ...
Glove asked 22/2, 2022 at 13:25
1
Solved
I was reading the GCC documentation on C and C++ function attributes. In the description of the error and warning attributes, the documentation casually mentions the following "trick":
e...
Exotic asked 23/1, 2022 at 3:51
1
Solved
In my workplace, we have this convention: almost every class (with very few exceptions) is implemented with unique_ptrs, raw pointers or references as member variables.
This is because of compilati...
Tooling asked 20/5, 2021 at 7:17
2
Solved
When working on compile time features it would be nice to echo something at compile time. If an echo is withing a macro it is already executed at compile time. But is it also possible to print some...
Joppa asked 19/2, 2017 at 12:28
1 Next >
© 2022 - 2025 — McMap. All rights reserved.