Comments (4)
Well there is P1073R0 that we might have some day.
from constexpr.
This is Scott Schurr's link-time hack that attempts to prevent accidental non-constexpr usage of a function. The idea is that if you accidentally call a function in a non-constexpr context, it will reference a symbol that is not defined and cause a link error. Notice that everything that is thrown is externed, but not defined anywhere.
This is definitely not portable, but it works (worked?) on some compilers. I hope in future there will be better ways to guard against non-constexpr usage. The constexpr parts of C++ are evolving fast at the moment, so this repo is a dated experiment at this point.
from constexpr.
Unfortunately, this doesn't work on MSVC anymore.
cx_sha256.h(24,26): error C7631: 'cx::err::`anonymous-namespace'::sha256_runtime_error': variable with internal linkage declared but not defined
It's also a warning on clang (-Wundefined-internal) but that can be disabled.
This thread has some ideas - could we use one of those instead?
https://stackoverflow.com/questions/39650122/how-to-ensure-constexpr-function-never-called-at-runtime
from constexpr.
There is consteval
in the C++20 standard now: https://en.cppreference.com/w/cpp/language/consteval
from constexpr.
Related Issues (9)
- License ? HOT 2
- Please allow the code to be compiled with exceptions disabled.
- integral constant overflow C4307 with compiler crash
- Counter Not Counting HOT 1
- Preposterous proposition
- Compilation with GCC < 9.0
- Library won't compile HOT 1
- Explicit specialization needed for cpp14_promoted<long double, long double>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.