Followers 0

# Unity A Proposal to Add Strong Type Aliases to the Standard Language

## 29 posts in this topic

Also, you can't do that with primitive types.

You could always write a "boxed type" template class that encapsulates a primitive type, while supporting the same operators the primitive type does. So, essentially reinventing Java's "boxed types" in C++ using templates. I'm not in a position to say whether that would be worth the effort, though. My guess would be that it isn't. Edited by Oberon_Command
0

##### Share on other sites
You could always write a "boxed type" template class that encapsulates a primitive type, while supporting the same operators the primitive type does. So, essentially reinventing Java's "boxed types" in C++ using templates. I'm not in a position to say whether that would be worth the effort, though. My guess would be that it isn't.
I have one of those in my engine, which acts like the type (operator wise), but with an explicit constructor from that type.
e.g. short version:
template<class T, class Tag> struct P
{
P() : value() {}
explicit P( T v ) : value(v) {}
T value;
};
struct MetreTag {};
struct InchTag {};
typedef P<float, MetreTag> Metre;
typedef P<float, InchTag> Inch;
And then I write conversion functions like:
Inch ToInches(Metre m) { return Inch(m.value * 39.3700787f); }
void test()
{
Metre m(10);
Inch i( ToInches(m) );
Inch error( m );//won't compile
}
I haven't used the boost solution, but I imagine it's similar to this, so I probably suffer from the same issues that SOTL found with boost's version. Edited by Hodgman
1

##### Share on other sites

Your version looks great for basic types (which mine doesn't support), but doesn't support classes (which mine does).

Most of my strong aliases have to do with a basic 'Point' type.

I could write a template just for points, but I figured in such a strongly-typed language as C++, why not have a generalized solution built into the language?

We did so for enums with the C++11 'enum class'.

0

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Followers 0

• ### Similar Content

• Hey guys, posting my work in progress for Macho Cat here.

A very early prototype for Macho Cat. Everything is just placeholder for now
What is Macho Cat?
A silly little game where you scrub the macho cat with random objects found in trash and junkyard to please him
Gameplay feature?
-Cat scrubbin, lots of scrubbin
-Unlock moar objects in junkyard
-Funny, silly and easy
When will the game release?
December 2017 (estimate)
Interested to Beta test?
opneongame@gmail.com

• Hey all,

As the heading says I'm trying to get my head around Goal Objective Action Planning AI.  However I'm having some issues reverse engineering Brent Owens code line-by-line (mainly around the recursive graph building of the GOAPPlanner).  I'm assuming that reverse engineering this is the best way to get a comprehensive understanding... thoughts?

Does anyone know if an indepth explanation on this article (found here: https://gamedevelopment.tutsplus.com/tutorials/goal-oriented-action-planning-for-a-smarter-ai--cms-20793), or another article on this subject?

I'd gladly post my specific questions here (on this post, even), but not too sure how much I'm allowed to reference other sites...

Any pointers, help or comments would be greatly appreciated.

Sincerely,

Mike
• By E-gore
Hi all,
This is our (xDBAGames) first game
Called Iron Dome Legacy.
It is a Missile Command clone. In this game you control the Israeli "Iron Dome" anti missile defence system.
Features:
The player has limited amount of missiles. The Iron dome system is upgradable. The money is determined by the outcome of a level. The game is free. There are only rewarded ads. We tried to create a game that has some context to the daily life, but we are sure not trying to be political here.
I hope you could try this game, and we will appreciate any comments.
xDBAGames is a company of two programmers. That have no experience in the video game industry, but have a lot of passion for games.

• By UNNYHOG
Hello, Colleagues!

We have been working on our newest Fantasy style Gesture based MOBA game for a long time and it's releasing on Steam on July 26. Meanwhile you can already try it out by downloading our launcher from the website.

Any feedback is welcome here. Thank you.

If you don't want to play, I would love to share with you our teaser :

• So I am working on a mobile game.
It uses slides for a story, the slides are very large. Each slide is almost 2048*2048; the max texture loading size I am using for the game.

My problem is that Unity keeps each slide in the memory after it's loaded, even when it will show only once per game. This leads to the game crashing on older mobiles.
My idea was to destroy each object after it was shown using a coroutine, so it deletes the past slide and loads the next slide. This worked because instead of crashing on 23 slides it crashed on 48 slides.
After some profiling I realized that destroy() isn't clearing all the memory that a slide used.

What I want to do now is assign a limited amount of memory as a slide slot. Then I need some way to unload the slide from the slot, freeing the slot for the next slide; without Unity storing the slides in the memory.
Any ideas on how I would do this?

• 12
• 28
• 14
• 11
• 36