Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C/C++ declare 2D/3D array with ascii art

Long time ago (10+ years) I saw a syntax which let you declare array with "ascii art".

Something like this:

//Declares 5x3 2d array
int myArray[] = #####
                #   #
                #####

It was even possible to draw a cuboid for 3d arrrays.

My primary language for a very long time is a C++, so I'm sure it was C/C++. My memory tells my that I read about it in some "C++ deprecated features" article, but I doubt this was ever in standard. Maybe it was some kind of a language extension.

It seems that I'm unable to come up with correct words to google it and it bothers me a lot :)

Does anybody has any idea is whether such syntax ever existed in some form?

like image 647
relaxxx Avatar asked Nov 16 '25 13:11

relaxxx


1 Answers

Sounds very much like Eelis' Multi-Dimensional Analog Literals (also linked here). Short example:

#include <cassert>

#include "analogliterals.hpp"
using namespace analog_literals::symbols;

int main()
{
    auto l = I---------I;

    auto r = o---------o
             |         !
             !         !
             o---------o;

    assert(l.length == 4);
    assert(r.width == 4 && r.height == 2);
}
like image 183
dxiv Avatar answered Nov 18 '25 05:11

dxiv



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!