Klang C++ 0.7.15
Language Reference (draft)
Loading...
Searching...
No Matches
klang::constant

Constant scalar (pre-converted to double, float and int). More...

#include <klang.h>

Public Member Functions

constexpr constant (double value) noexcept
 Create a constant from the given value.
 
constexpr operator float () const noexcept
 
float operator^ (float x) const
 Constant raised to the power, x.
 
float operator^ (int x) const
 
float operator^ (double x) const
 

Public Attributes

const double d
 Constant as double.
 
const float f
 Constant as float.
 
const int i
 Constant as integer.
 
const float inv
 Inverse of constant.
 

Detailed Description

Definition at line 154 of file klang.h.

Constructor & Destructor Documentation

◆ constant()

klang::constant::constant ( double value)
inlineconstexprnoexcept

Definition at line 157 of file klang.h.

158 : d(value), f(static_cast<float>(value)), i(static_cast<int>(value)), inv(value == 0.0f ? 0.0f : static_cast<float>(1.0 / value)) {
159 }
const float inv
Inverse of constant.
Definition klang.h:164
const double d
Constant as double.
Definition klang.h:161
const float f
Constant as float.
Definition klang.h:162
const int i
Constant as integer.
Definition klang.h:163

Member Function Documentation

◆ operator float()

klang::constant::operator float ( ) const
inlineconstexprnoexcept

Definition at line 166 of file klang.h.

166{ return f; }

References f.

◆ operator^() [1/3]

float klang::constant::operator^ ( double x) const
inline

Definition at line 171 of file klang.h.

171{ return static_cast<float>(std::pow(d, x)); }

References d.

◆ operator^() [2/3]

float klang::constant::operator^ ( float x) const
inline

Definition at line 169 of file klang.h.

169{ return std::pow(f, x); }

References f.

◆ operator^() [3/3]

float klang::constant::operator^ ( int x) const
inline

Definition at line 170 of file klang.h.

170{ return static_cast<float>(std::pow(d, x)); }

References d.

Member Data Documentation

◆ d

const double klang::constant::d

Definition at line 161 of file klang.h.

Referenced by operator^(), and operator^().

◆ f

◆ i

const int klang::constant::i

Definition at line 163 of file klang.h.

◆ inv