Last active
April 23, 2018 09:17
-
-
Save 5shekel/2c096206ffe347059da4aa787784db41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//see http://arduino.land/FAQ/content/6/32/en/passing-arrays-to-functions.html#pass-multi-by-pointer | |
int arr_3Da[1][2][3] { | |
{ | |
{1, 2, 3}, | |
{4, 5, 6} | |
} | |
}; | |
int arr_3Db[2][2][3] { | |
{ | |
{1, 2, 3}, | |
{4, 5, 6}, | |
}, | |
{ | |
{1, 2, 3}, | |
{4, 5, 6}, | |
} | |
}; | |
void setup() { | |
Serial.begin(115200); | |
Serial.println(sizeof(arr_3Da)); | |
passme_3D(arr_3Da); | |
//but following will throw error | |
//passme_3D(arr_3Db); | |
} | |
void passme_3D(int (&seq)[1][2][3]) { | |
Serial.println(sizeof(seq)); | |
} | |
void loop() { | |
} | |
/* | |
// "magic" of tamplates | |
template< typename T, size_t N > | |
void Func( T (&array)[N] ) { | |
//code here | |
} | |
template< typename T, size_t N, size_t X > | |
void Func( T (&array)[N][X] ) { | |
//Code here | |
} | |
template< typename T, size_t N, size_t X, size_t Y > | |
void Func( T (&array)[N][X][Y] ) { | |
//Code here | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment