How can I instantiate a template with a type determined at runtime?

Hello,

I need to instantiate a std::vector, but its type depends on something that I would not know until runtime:

#include <vector>
if (some_condition)
std::vector<float> myVector;
else
std::vector<int32_t> myVector;

I know this does not work because,in order to instantiate a template class, the data type must be known at compile time.

I've seen some people suggest std::variant but I have not understood it completely.

Also, how do different libraries (like ONNX) provide different data types? Do they use templates?

PS : I am not developing a library.

EDIT:

I need to create an array or a vector to act as a placeholder (allocator) for input tensors. But this vector requires a different amount of space based on the size and type of the input. The size is easily manageable per instance of the parent class if we only had one type, but we don't.

The thing is, there are some arguments that need to be set for this specific project that determine what exactly the size of the array would be, and they are only known when you parse an ONNX model at runtime.

reddit.com
u/CommandShot1398 — 1 day ago

Which post company is the most reliable for sending a sensitive document to germany?

Hi everyone,

I apologize for writing in English; I am only at A1 level in German at the moment.

I need to send some documents to Germany; they are sensitive in a manner that, if they are lost or damaged, it's one hell of a maze to get a 2nd copy of them.

Which posting company is the most reliable for this?

reddit.com
u/CommandShot1398 — 6 days ago

Help needed for a future path.

Hello everyone.

I have a project for my PhD (it is relevant because I need you to have an understanding of its scope), which requires me to design an automated system consisting of multiple sensors and complicated logic that needs to run for days. I know Python and C++ to some extent. I need to make some decisions to proceed with.

Due to the nature of the project, the whole system needs to be synchronized between physical events, captures, and actuators, and all of them must be running at the same time, so multithreading/multiprocessing is definitely needed. Also, reliability and maintenance are essential.

I have 3 YOE with Python and SWE as a whole, but with C++, I have only made a couple of small projects. What I am looking for in this project is

1- An opportunity to advance my knowledge and experience in SWE and system design.

2- Improve my HW and embedded knowledge

3- To have a nice foundation to continue my career as an engineer (yes, I like it more than science) after I finish my PhD.

Given all of these, even though conceptually it might be much, much simpler for me to do it with Python, I want to go with C++, because it's my favourite language and also it has a better future. Also, how often does one get a chance to mess up and learn while getting paid for it?

Now, to the questions.

1- Which version should I focus on that is established in the industry?

2- What advice or heads-up do the veterans here have for me?

3- Any resource that you might use when you hit a wall, and AI is producing nonsense to solve it (Please don't refer to the official documentation)?

4- Is there any sort of standard environment that I should go with?

5- What general libraries (such as Boost) do you recommend using that are also heavily used in the industry and give me an upper hand for job hunting?

6- Any advice that you think might be useful is appreciated.

reddit.com
u/CommandShot1398 — 12 days ago

Which version should I use?

Hello everyone.

I have a project for my PhD (it is relevant because I need you to have an understanding of its scope), which requires me to design an automated system consisting of multiple sensors and complicated logic that needs to run for days. I know Python and C++ to some extent. I need to make some decisions to proceed with.

Due to the nature of the project, the whole system needs to be synchronized between physical events, captures, and actuators, and all of them must be running at the same time, so multithreading/multiprocessing is definitely needed. Also, reliability and maintenance are essential.

I have 3 YOE with Python and SWE as a whole, but with C++, I have only made a couple of small projects. What I am looking for in this project is

1- An opportunity to advance my knowledge and experience in SWE and system design.

2- Improve my HW and embedded knowledge

3- To have a nice foundation to continue my career as an engineer (yes, I like it more than science) after I finish my PhD.

Given all of these, even though conceptually it might be much, much simpler for me to do it with Python, I want to go with C++, because it's my favourite language and also it has a better future. Also, how often does one get a chance to mess up and learn while getting paid for it?

Now, to the questions.

1- Which version should I focus on that is established in the industry?

2- What advice or heads-up do the veterans here have for me?

3- Any resource that you might use when you hit a wall, and AI is producing nonsense to solve it (Please don't refer to the official documentation)?

4- Is there any sort of standard environment that I should go with?

5- What general libraries (such as Boost) do you recommend using that are also heavily used in the industry and give me an upper hand for job hunting?

6- Any advice that you think might be useful is appreciated.

reddit.com
u/CommandShot1398 — 12 days ago

Cheapest option for round trip to Kufstein

Guten Tag!

So, I need to commute between Innsbruck and Kufstein for a doctor's appointment (I know, right?), but the cheapest train I found is 22.5 Euros each way, which seems very expensive while Innsbruck to Wien is sometimes as low as 45 euros.

Is there any other cheaper way that doesn't make me feel like I am being ripped off?

Thank you all.

reddit.com
u/CommandShot1398 — 17 days ago

What is the fighter jet like sounds all about? ( Right now)

So our apartment is kinda near the airport and I know what sound is for the commercial planes.

The ones I heard just about now (23:37-39) are not commercial.

What are these? Are these related to the operation that the US is doing in Iran? Especially since the fastest route to Iran from Germany passes Tirol.

I know Austria is neutral but I read that the US violated air space a couple of times.

reddit.com
u/CommandShot1398 — 1 month ago
▲ 0 r/FinanzenAT+1 crossposts

What investments funds are reliable for expats?

Hi everyone, as the title says, I'm an expat here. Non EU, non US CITIZEN I don't want to keep all my money in the bank because, as you know, it will lose its value. Also, I don't have the knowledge or skill to invest it on my own.

I want to go through investment funds or trust funds for this.

There are a few criteria that I would like to meet as well.

1- It must be usable for expats because I am an expat.

2- It should be in a way that I can take my money easily.

3- I would like to invest through a company that is Austrian, or at least benefits Austrian people. Simply because you and your beautiful country have been very nice to me, and I would like to return the favour as much as possible (I don't make millions though :)) ).

reddit.com
u/CommandShot1398 — 2 months ago

Where can I get cheap protein shakes?

Servus dear Austrians.

So, let's jump to the question. I'm doing PhD here (to give you some context why I am looking for cheap ones😂), and started to go to the gym after a long time. I noticed that Höfer has Milsani shakes for around 4.5 euros per litre (330 ml for 1.59).

Which is not expensive to be fair, but I wonder if there is anything cheaper, with acceptable quality of course, available. Because of I take 1 a day, thats around 50 euros, which is like 7 kg of chicken breast at Höfer.

Thank you guys in advance.

reddit.com
u/CommandShot1398 — 2 months ago

Will this new rules affect me?

Hello everyone. I hope you are having a good day.

I have something in my mind that is bugging me.

​

I am an immigrant, a legal one, in one of the German speaking countries. Came here on a researcher visa to do science. Given all the stuff that are going on regarding immigrants, I am kinda questioning my future here.

​

First of all, I love it here. I love the people. I love the culture and I love the nature.

​

I don't want now nor in the future to practice the culture that I came from. I have zero religious beliefs of any sort.

​

However, given all the stuff that has been going on, I am kinda skeptical about my future here.

​

I want to be a positive part of the society in Europe. Contribute to the society, help it advance and be better in any way that I can. Simply because I like it here the way it is, I like the mindset of people here and I wish it could be preserved in the best way possible.

​

I know that I will never be a European because I was not born here, but I am afraid that I might face harsh rejections in the society since I am not from here.

​

In your perspective, how would the future play out for someone like me? Any answers are welcome. Even the ones suggesting me to go back where I came from.

reddit.com
u/CommandShot1398 — 2 months ago

My wife was verbally harassed, what should I do?

Hello everyone,

Today my wife was walking on bridge between Innrain and Fischnalerstraß on road 174, and some car has pulled over and harassed her verbally, calling her words like "sexy" "give me you number" and other stuff like that (In German of course but I don't know German, she does).

She has severe anxiety and that was the first time and I convinced her to go out on her own in a very long time.

What can I do about it? Do such stuff happen often here in the city? Any help is welcome. (We are farley new in Austria)

reddit.com
u/CommandShot1398 — 3 months ago