Questions tagged [downcast]
Downcasting permits an object of a superclass type to be treated as an object of any subclass type.
downcast
599
questions
0
votes
1
answer
61
views
Downcasting a type with a named lifetime parameter
I have the following code:
use std::any::Any;
use std::borrow::Cow;
// Base trait for downcasting
pub trait AsTranslationUnit<'a> {
fn as_any(&self) -> &dyn Any;
}
pub trait ...
0
votes
2
answers
128
views
Can reinterpret_cast be considered as an unsafe workaround when dynamic_cast is unavailable? [duplicate]
I am using C++ to write some components in a toy x86 kernel, and I was in a situation where I had to downcast a pointer type. I had an interface and its implementation like this,
class ITerminalWriter ...
1
vote
0
answers
97
views
Polars Downcast the Datatype without Precision Loss
I've observed that when I use polars.Expr.shrink_dtype to optimize the datatype of columns, it often alters the float values slightly.
For instance, a float64 value of 2.7 becomes 2.7000001 when ...
1
vote
0
answers
79
views
c++ downcast to unknown derived class inside function which takes pointer to base class
I have code with a lot of data classes 'CustomData1' ... 'CustomDataN' with different structure but with the same base class 'DataBase'. Some another class 'Controller' should process data passed to '...
0
votes
1
answer
41
views
How to downcast the Binding<struct> on protocol in SwiftUI?
I want to access label property with binding which is only in ComponentWithLabel protocol. But I cannot downcast the binding of any Component on any ComponentWithLabel and access the label property. ...
0
votes
1
answer
81
views
C++ using a vector of base classes to automate running several derived but with access to derived class attributes
I am in a situation where I need to run several image processing filters F1, F2 etc., all deriving from base class Filter and each overriding its virtual method run(). Each derived filter has a ...
28
votes
4
answers
27k
views
pandas FutureWarning: Downcasting object dtype arrays on .fillna, .ffill, .bfill is deprecated and will change in a future version
In order to print dataframes nicely using tabulate, so that NaN and NaT are printed as empty cells, I've been using this successfully:
print(tabulate(df.astype(object).fillna("")))
Now, ...
1
vote
1
answer
57
views
Cannot downcast logger back to original struct
I would like to access my log::Log impl instance in order to access a particular field, but once I receive the reference I am not able to downcast it to my struct.
I tried to convert the logger ...
2
votes
1
answer
229
views
When can static_cast be used safely for downcasting in C++? [duplicate]
I need to know under which conditions static_cast can be used in order to convert a parent class pointer to a child class pointer without causing an undefined behavior.
Usually dynamic_cast is ...
0
votes
0
answers
112
views
CKEditor 5 nested elements not downcasting properly
I have the following series of nested plugins/elements that are used for creating documents/emails:
MultiRow > Row > Cell
I have attributes at the Row level that are edited through a UI that is ...
0
votes
1
answer
57
views
Downcasting an array of type Comparable[] to generic <T extends Comparable<T>>
So, recently I've been trying to implement my own array of generic comparable type and my class contains a private field T[] array, the problem is that for my implementation of sorting algorithm I ...
0
votes
1
answer
166
views
CKEditor5: How to integrate a SVG sprite as a widget?
I'm trying to use CKEditor5 here to correctly cast an SVG sprite element and display it as a widget, but unfortunately I'm only partially succeeding.
The HTML element to be cast looks like this:
<...
0
votes
2
answers
96
views
Downcasting base class instance to empty child interface
I was wondering about the validity of downcasting a base child to an empty interface child class. See example below. Basically I want to store data in a generic template free way (reading data from a ...
0
votes
0
answers
288
views
Downcasting from an Arc<Mutex<dyn Trait>> in Rust? [duplicate]
I have a structure like this:
use std::sync::{Arc, Mutex, MutexGuard};
trait MyTrait {
fn do_something(&self);
}
#[derive(Clone)]
struct Wrapper {
object: Arc<Mutex<dyn MyTrait>&...
1
vote
1
answer
48
views
How does the downcast logic in pd.to_numeric decide when to downcast from Float64 to Float32?
I am trying to understand the logic behind pd.to_numeric float downcasting. I'm looking for the specific condition(s) that are used.
I was hoping / expecting that it would preserve the uniqueness of ...