modern | Modern C for the Windows Runtime | File Utils library
kandi X-RAY | modern Summary
kandi X-RAY | modern Summary
Modern is a Standard C++ language projection for the Windows Runtime. The Modern compiler produces a header-only library designed to provide Standard C++ developers with first-class access to the modern Windows API.
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 modern
modern Key Features
modern Examples and Code Snippets
import {Environment, Network, RecordSource, Store} from 'relay-runtime';
import {execute, makePromise} from 'apollo-link';
import {HttpLink} from 'apollo-link-http';
import {parse} from 'graphql';
const link = new HttpLink({
uri: 'http://localhost
function setModernOffsets(node, offsets) {
if (!window.getSelection) {
return;
}
var selection = window.getSelection();
var length = node[getTextContentAccessor()].length;
var start = Math.min(offsets.start, length);
var end = typeof
Community Discussions
Trending Discussions on modern
QUESTION
I am reading a book on writing modern C++ code for microcontrollers which is named "Real time C++". I am trying to write the codes in the book myself. However, while copying the code from the book and trying to build it, I got a compilation error of:
error C2131: expression did not evaluate to a constant.
message : a non-constant (sub-) expression was encountered
I inserted the relevant part of the code below:
...ANSWER
Answered 2022-Jan-03 at 20:42It is unclear what the intention behind the reinterpret_cast
is, but the program is ill-formed.
constexpr
on a variable requires that the initializer is a constant expression. But an expression is disqualified from being a constant expression if it would evaluate a reinterpret_cast
. Therefore the initialization is ill-formed.
However, nothing else in the initialization stops it from being a constant expression and so
QUESTION
I am trying to add Simplebar scrollbar to the MUI Material Autocomplete component, instead of the default browser one. All works but doing that I've lost the ability to navigate the options list with the keyboard.
There is this snippet from the MUI docs
ListboxComponent If you provide a custom ListboxComponent prop, you need to make sure that the intended scroll container has the role attribute set to listbox. This ensures the correct behavior of the scroll, for example when using the keyboard to navigate.
But I have no idea how to do that.
The following code is from the MUI docs, first autocomplete example with custom ListboxComponenet and shortened movie list. (https://mui.com/components/autocomplete/)
...ANSWER
Answered 2021-Dec-30 at 20:06The problem is actually very complicated. Looking at its implementation, doesn't pass either the React
ref
or the role
prop to the correct element. The correct element I believe is .scrollbar-content
, which is very deeply nested and basically untouchable.
ETA: In case you thought of getting cheesy with document.querySelectorAll
setAttribute
shenanigans, that will not work. The ref
also needs to point at the correct element, and I don't think that's codeable on the workspace side.
The cleanest solution I can think of is to use Yarn 3 (👍) and patch simplebar-react
yourself, passing the needed props to .scrollbar-content
. Then you do:
QUESTION
I'm currently studying Jetpack Compose in an attempt to build a feature-rich application using modern Android architecture components. Traditionally, each screen (or navigation unit) in my application would be either an activity or a fragment, each with its own lifecycle bindings, but with Jetpack Compose and the Compose Navigation library, I would do something like this:
MainActivity.kt
:
ANSWER
Answered 2021-Aug-29 at 04:50The Compose application is designed to be used in a single-activity architecture with no fragments.
You can still have multiple activities or fragments and use setContent
in each of them, but in this case the transfer of data between activities falls on your shoulders. Use this approach if you're adding new Compose screens to an existing application built the old way.
But with Compose, it's much easier to do all the navigation within a single activity using Compose Navigation. Much less code, better performance due to no unnecessary code layers, easy to transfer data, etc.
To work with the view lifecycle, check out compose side-effects:
LaunchedEffect
can be used to execute an action when the view appears. It also runs on a coroutine context that is bound to the current composable: you can easily run suspend functions, and when the view disappears from view hierarchy - the coroutine will be canceled.DisposableEffect
can be used to subscribe to/unsubscribe from callbacks.
When you rotate the screen, all effects will restart no matter which key you passed.
QUESTION
I'm using C# (.NET 5). Imagine I have a class that stores an array of structures (say, floats):
...ANSWER
Answered 2021-Dec-10 at 19:57To write you can do something like this:
QUESTION
I work for an org that has a number of internal packages that were created many years ago. These are in the form of package zip archives that were compiled on Windows on R 3.x
. Therefore, they can't be installed on R 4.x
, and can't be used on Macs or Linux either without being recompiled. So everyone in the entire org is stuck on R 3.6
until this is resolved. I don't have access to the original package source files. They are lost to time....
I want to take these packages, extract the code and data, and update them for modern best practices (roxygen
, GitHub repos, testthat
etc.). What is the best way of doing this? I have a fair amount of experience with package development. I have already tackled one. I started a new RStudio package project, and going function by function, copying the function code to a new script file, getting and reformatting the help from the help browser as roxygen docs. I've done the same for any internal hidden functions that i could find (via pkg_name:::
mostly) , and also the internal datasets. That is all fairly straightforward, but very time consuming. It builds ok, but I haven't yet tested the actual functionality of the code.
I'm currently stuck because there are a couple of standardGeneric
method functions for custom S4 class objects. I am completely unfamiliar with these and haven't been able to figure out how to copy them over. Viewing the source code they are wrapped in new()
with "standardGeneric"
as the first argument (plus a lot more obviously), as opposed to just being a simple function
definition for all the other functions. Any help with how to recreate or copy these over would be very welcome.
But maybe I am going about this the wrong way in the first place. I haven't been able to find any helpful suggestions about how to "back engineer" R package source files from a compiled version.
Anyone any ideas?
...ANSWER
Answered 2021-Nov-15 at 15:23Check out if this works in R 3.6
.
Below script can automate least part of your problem by writing all function sources into separate and appropriately named .R
files. This code will also take care of hidden functions.
QUESTION
Using AT&T syntax on x86-64, I wish to assemble c = a + b;
as
ANSWER
Answered 2021-Nov-17 at 05:12Only a few specific GPR instructions have VEX encodings, primarily the BMI1/BMI2 instructions that were added after AVX already existed. See the list in Table 2-28, which has ANDN, BEXTR, BLSI, BLSMSK, BLSR, BZHI, MULX, PDEP, PEXT, RORX, SARX, SHLX, SHRX
, as well as the same list in 5.1.16.1. For example, andn
's manual entry lists only a VEX encoding, and
's manual entry doesn't list any.
So Intel (unfortunately) didn't introduce a brand new three-operand alternate encoding for the entire instruction set. They just introduced a few specific instructions that take three operands and use VEX for it. In some cases these have similar or equivalent functionality to an existing instruction, e.g. SHLX
for SHL
with a variable count, and so effectively provide a three-operand version of the previous two-operand instruction, but only in those special cases. There are not equivalent instructions across the board.
The "old style" two-operand form remains the only version of the add
instruction. However, as fuz points out in comments, lea
can be a good way to add two registers and write the result to a third, subject to some restrictions on operand size.
See Using LEA on values that aren't addresses / pointers? for more general things LEA can do, like copy-and-add a constant to a register, or shift-and-add. Compilers already know this and will use lea
where appropriate, any time it saves instructions. (Or with some tune options like -mtune=atom
for old in-order Atom, will use lea
even when they could have used add
.)
If more flexible encodings of common integer instructions other than add existed, like and
/xor
/sub
, gcc -O3 -march=skylake
would already be using them in its own asm output, without needing inline asm. Or if alternative instructions could get the job done, like lea
for add
, would be doing that, so it makes sense to look at compiler output to see what tricks it knows. Trying it yourself would make more sense as something to play around with in a stand-alone .s
file that just makes an exit system call, or just to single-step, removing the complexity of using inline asm. (GAS by default doesn't restrict instruction-sets. gcc -march=skylake
doesn't pass that on to the assembler, as
.)
In your inline asm, your c
operand should be to output-only: =r
instead of +r
. The old value is overwritten, so there's no need to tell the compiler to produce it as an input. (Like you said, you want c = a+b
not c += a+b
.)
Using a single lea
as the asm template means you don't need a =&r
early-clobber output, because your asm will read all its inputs before writing that output. In your case, having it as an input/output was probably stopping the compiler from choosing the same register as one of the inputs, which could have broken with mov; add
.
QUESTION
The code I work on has a substantial amount of floating point arithmetic in it. We have test cases that record the output for given inputs and verify that we don't change the results too much. I had it suggested that I enable -march native to improve performance. However, with that enabled we get test failures because the results have changed. Do the instructions that will be used because of access to more modern hardware enabled by -march native reduce the amount of floating point error? Increase the amount of floating point error? Or a bit of both? Fused multiply add should reduce the amount of floating point error but is that typical of instructions added over time? Or have some instructions been added that while more efficient are less accurate?
The platform I am targeting is x86_64 Linux. The processor information according to /proc/cpuinfo
is:
ANSWER
Answered 2021-Nov-15 at 09:40-march native
means -march $MY_HARDWARE
. We have no idea what hardware you have. For you, that would be -march=skylake-avx512
(SkyLake SP) The results could be reproduced by specifying your hardware architecture explicitly.
It's quite possible that the errors will decrease with more modern instructions, specifically Fused-Multiply-and-Add (FMA). This is the operation a*b+c, but rounded once instead of twice. That saves one rounding error.
QUESTION
This code to read a uint64_t
as two uint32_t
is UB due to the strict aliasing rule:
ANSWER
Answered 2021-Nov-11 at 18:47QUESTION
I have install Python 3.10 on Windows 10.
Then I installed numpy and matplotlib without problem.
But when I try to install scipy, I get a ton of errors.
The install sequence is below.
Is this related to needing MKL/BLAS libraries? If so, what should I install?
...ANSWER
Answered 2021-Oct-31 at 13:24In scipy's PyPI page, it looks like scipy doesn't support 3.10 as the meta says
QUESTION
Since 1 or 2 days my old php container (dockerhub php:5.4-apache) can't use curl anymore. this is the log when running curl inside this container.
...ANSWER
Answered 2021-Oct-03 at 00:09the reason is cacerts of the os are outdated
To update them you need to do the following
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install modern
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