GithubHelp home page GithubHelp logo

constexpr's People

Contributors

elbeno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

constexpr's Issues

Counter Not Counting

Counter does not seem to be counting up.

∴ clang -std=c++1z -I../include cx_counter.cpp 
cx_counter.cpp:6:3: error: static_assert failed "counter(1)"
  static_assert(cx::counter() == 1, "counter(1)");
  ^             ~~~~~~~~~~~~~~~~~~
cx_counter.cpp:7:3: error: static_assert failed "counter(2)"
  static_assert(cx::counter() == 2, "counter(2)");
  ^             ~~~~~~~~~~~~~~~~~~
cx_counter.cpp:8:3: error: static_assert failed "counter(3)"
  static_assert(cx::counter() == 3, "counter(3)");
  ^             ~~~~~~~~~~~~~~~~~~
3 errors generated.

Compilation with GCC < 9.0

With GCC < 9.0, the bug 67371 - Never executed "throw" in constexpr function fails to compile gives errors.

It has been solved for GCC >= 9.0 with 86678 - constexpr evaluation incorrectly diagnoses unevaluated call to non-constexpr function.

A workaround is to add in "cx_math.h":

// GCC
//  Bug 67371 - Never executed "throw" in constexpr function fails to compile
//  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86678
//  Fixed for GCC 9.
#if defined(__GNUC__) && (__GNUC__ < 9)
#  define BUG_67371
#endif

and modify the constexpr long double floor(long double x) and constexpr long double ceil(long double x) functions the following way:

[...]
#ifndef BUG_67371
  throw err::ceil_runtime_error();
#endif  // BUG_67371
[...]

License ?

Hey

Please could you say which license you're releasing this under.
Thank you!

Explicit specialization needed for cpp14_promoted<long double, long double>

Hi,

The partial specializations provided for cpp14_promoted in cx_math.h (https://github.com/elbeno/constexpr/blob/master/src/include/cx_math.h#L872) are ambiguous.

This can also be seen by testing with some main stream compilers: https://godbolt.org/z/rGfcGzKfh

The easiest fix is to provide an explicit specialization for when the types are both long double:

  template <  >
  struct cpp14_promoted < long double , long double >
  {
    using type = long double ;
  } ;

integral constant overflow C4307 with compiler crash

I cannot use the string encryption at all. Throws errors immediately and crashes the compiler with "Internal error during IMAGE:BuildImage" LNK1000 and MSB6006 "link.exe" exited with code 1000 and C1001 "An internal error has occurred in the compiler." Using Visual Studio 2015 Update 2

What's in my code:

include "cx_strenc.h"

define strenc( s ) std::string( cx_make_encrypted_string( s ) )

void Test()
{
std::string test = strenc("Test String");
}

Library won't compile

error: ‘struct cx::array<T, N>::inserter<I, typename std::enable_if<(I == 0)>::type>’ redeclared with different access

Preposterous proposition

Consider the following IEEEish assumption:
The widest floating point type can't exactly represent a bigger range of integers than the widest integer type. (that is, if we exceed the limits of widest int we're in a zone that is definitely not precise enough to have a fractional part, since it's not even good enough for integers)

I understand that this is quite dubious, almost unacceptable and nearly heretical, but look at my glorious trunc!

template <typename IntMax = std::intmax_t, typename Float = float>
[[nodiscard]] constexpr
Float trunc(Float f)
{
	return abs(f) <= std::numeric_limits<IntMax>::max()
		? static_cast<IntMax>(f)
		: f;
}

The use of "return true ? <object> : <exception>" syntax in code

I was wondering as to the nature of the syntax appearing many times in your code, with the use of the ternary operator, for example:
return true ? detail::md5::md5(s) : throw err::md5_runtime_error;

What is the benefit of this? why not just return detail::md5::md5(s)?
After all, to my understanding, the exception will never be evaluated at runtime. Maybe there is some added value to this at compile time? If so, what is it?

thank you in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.