# C++ question - templated function aliases.

**URL:** <https://boards.straightdope.com/t/c-question-templated-function-aliases/376286>\
**Category:** Factual Questions\
**Created:** [October 13, 2006, 9:48am UTC](https://boards.straightdope.com/t/c-question-templated-function-aliases/376286 "2006-10-13T09:48:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Capt.Ridley\_s\_Shooting\_Party](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@Capt.Ridley\_s\_Shooting\_Party](https://boards.straightdope.com/u/Capt.Ridley_s_Shooting_Party)\
**Post date:** [October 13, 2006, 9:48am UTC](https://boards.straightdope.com/t/c-question-templated-function-aliases/376286/1 "2006-10-13T09:48:35Z")

</div>

I have a templated Matrix class with some templated functions that operate on them, including a function for producing identity matrices:

```auto

	template<typename T, int iSize, int jSize>
			Matrix<T, iSize, iSize> identity(const T& identity)
			{
				Matrix<T, iSize, iSize> m;
				for(int i = 0; i < iSize; ++i)
					m.set(i, i, identity);
				return m;
			}

```

I have some typdefs for common matrix sizes and types:

```auto

	typedef Matrix<int, 4, 4> Matrix44i;
	typedef Matrix<float, 4, 4> Matrix44f;

```

Is it possible to create some sort of alias to identity\<int, 4, 4\>(1) so I can refer to it as identity44i?

---

<div class="post-metadata">

**Author:** ![Capt.Ridley\_s\_Shooting\_Party](https://avatars.discourse-cdn.com/v4/letter/c/cc9497/32.png) [@Capt.Ridley\_s\_Shooting\_Party](https://boards.straightdope.com/u/Capt.Ridley_s_Shooting_Party)\
**Post date:** [October 13, 2006, 12:55pm UTC](https://boards.straightdope.com/t/c-question-templated-function-aliases/376286/2 "2006-10-13T12:55:06Z")

</div>

Ignore the question, I just created a constant.
