literal_ipaddr | C17 constexpr implementation of inet_addr / inet_aton / | File Utils library
kandi X-RAY | literal_ipaddr Summary
kandi X-RAY | literal_ipaddr Summary
C++17 constexpr implementation of inet_addr / inet_aton / inet_pton
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of literal_ipaddr
literal_ipaddr Key Features
literal_ipaddr Examples and Code Snippets
Community Discussions
Trending Discussions on literal_ipaddr
QUESTION
I'm trying to use https://github.com/gdelugre/literal_ipaddr which says it is a
C++17 constexpr implementation of inet_addr / inet_aton / inet_pton
When I do:
...ANSWER
Answered 2019-Dec-18 at 01:50ipSourceAddress
does not get its value at compile time (as-if rule nonwithstanding).
ip
's value is not usable in a constant expression since it is not declared constexpr
and doesn't qualify for one of the other exceptions to the rule of lvalue-to-rvalue conversion in a constant expression. Therefore IPAddr::inet_pton(ip)
is not a constant expression.
You can see this clearly by making ipSourceAddress
constexpr
(which auto
does not imply).
constexpr
on a variable requires initialization at compile-time and because the initializer is not a constant expression it will fail.
See godbolt.
I don't know how you come to a different conclusion.
Note however that the library does seem to require that the char
array passed to it is exactly as long as the string it contains (plus null-terminator). It fails if you hand it a longer array and outputs the value you are seeing.
See godbolt.
It seems the author intends the functions to only be called directly with string literals.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install literal_ipaddr
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page