C++ std::to_array is undefined - c++
I am using C++ Language Standard C++ 17.
I have been trying to make std::to_array to work but it's telling me it's not a member of namespace std.
My code:
#include <algorithm>
#include <array>
#include <string_view>
#include <Windows.h>
#include "InputUtil.h"
#define WIN32_LINUX(win32, linux) win32
struct Key {
constexpr Key(std::string_view name, int code) : name{ name }, code{ code } { }
std::string_view name;
int code;
};
static constexpr auto keyMap = std::to_array<Key>({
{ "'", WIN32_LINUX(VK_OEM_7, SDL_SCANCODE_APOSTROPHE) },
{ ",", WIN32_LINUX(VK_OEM_COMMA, SDL_SCANCODE_COMMA) },
{ "-", WIN32_LINUX(VK_OEM_MINUS, SDL_SCANCODE_MINUS) },
{ ".", WIN32_LINUX(VK_OEM_PERIOD, SDL_SCANCODE_PERIOD) },
{ "/", WIN32_LINUX(VK_OEM_2, SDL_SCANCODE_SLASH) },
{ "0", WIN32_LINUX('0', SDL_SCANCODE_0) },
{ "1", WIN32_LINUX('1', SDL_SCANCODE_1) },
{ "2", WIN32_LINUX('2', SDL_SCANCODE_2) },
{ "3", WIN32_LINUX('3', SDL_SCANCODE_3) },
{ "4", WIN32_LINUX('4', SDL_SCANCODE_4) },
{ "5", WIN32_LINUX('5', SDL_SCANCODE_5) },
{ "6", WIN32_LINUX('6', SDL_SCANCODE_6) },
{ "7", WIN32_LINUX('7', SDL_SCANCODE_7) },
{ "8", WIN32_LINUX('8', SDL_SCANCODE_8) },
{ "9", WIN32_LINUX('9', SDL_SCANCODE_9) },
{ ";", WIN32_LINUX(VK_OEM_1, SDL_SCANCODE_SEMICOLON) },
{ "=", WIN32_LINUX(VK_OEM_PLUS, SDL_SCANCODE_EQUALS) },
{ "A", WIN32_LINUX('A', SDL_SCANCODE_A) },
{ "ADD", WIN32_LINUX(VK_ADD, SDL_SCANCODE_KP_PLUS) },
{ "B", WIN32_LINUX('B', SDL_SCANCODE_B) },
{ "BACKSPACE", WIN32_LINUX(VK_BACK, SDL_SCANCODE_BACKSPACE) },
{ "C", WIN32_LINUX('C', SDL_SCANCODE_C) },
{ "CAPSLOCK", WIN32_LINUX(VK_CAPITAL, SDL_SCANCODE_CAPSLOCK) },
{ "D", WIN32_LINUX('D', SDL_SCANCODE_D) },
{ "DECIMAL", WIN32_LINUX(VK_DECIMAL, SDL_SCANCODE_KP_DECIMAL) },
{ "DELETE", WIN32_LINUX(VK_DELETE, SDL_SCANCODE_DELETE) },
{ "DIVIDE", WIN32_LINUX(VK_DIVIDE, SDL_SCANCODE_KP_DIVIDE) },
{ "DOWN", WIN32_LINUX(VK_DOWN, SDL_SCANCODE_DOWN) },
{ "E", WIN32_LINUX('E', SDL_SCANCODE_E) },
{ "END", WIN32_LINUX(VK_END, SDL_SCANCODE_END) },
{ "ENTER", WIN32_LINUX(VK_RETURN, SDL_SCANCODE_RETURN) },
{ "F", WIN32_LINUX('F', SDL_SCANCODE_F) },
{ "F1", WIN32_LINUX(VK_F1, SDL_SCANCODE_F1) },
{ "F10", WIN32_LINUX(VK_F10, SDL_SCANCODE_F10) },
{ "F11", WIN32_LINUX(VK_F11, SDL_SCANCODE_F11) },
{ "F12", WIN32_LINUX(VK_F12, SDL_SCANCODE_F12) },
{ "F2", WIN32_LINUX(VK_F2, SDL_SCANCODE_F2) },
{ "F3", WIN32_LINUX(VK_F3, SDL_SCANCODE_F3) },
{ "F4", WIN32_LINUX(VK_F4, SDL_SCANCODE_F4) },
{ "F5", WIN32_LINUX(VK_F5, SDL_SCANCODE_F5) },
{ "F6", WIN32_LINUX(VK_F6, SDL_SCANCODE_F6) },
{ "F7", WIN32_LINUX(VK_F7, SDL_SCANCODE_F7) },
{ "F8", WIN32_LINUX(VK_F8, SDL_SCANCODE_F8) },
{ "F9", WIN32_LINUX(VK_F9, SDL_SCANCODE_F9) },
{ "G", WIN32_LINUX('G', SDL_SCANCODE_G) },
{ "H", WIN32_LINUX('H', SDL_SCANCODE_H) },
{ "HOME", WIN32_LINUX(VK_HOME, SDL_SCANCODE_HOME) },
{ "I", WIN32_LINUX('I', SDL_SCANCODE_I) },
{ "INSERT", WIN32_LINUX(VK_INSERT, SDL_SCANCODE_INSERT) },
{ "J", WIN32_LINUX('J', SDL_SCANCODE_J) },
{ "K", WIN32_LINUX('K', SDL_SCANCODE_K) },
{ "L", WIN32_LINUX('L', SDL_SCANCODE_L) },
{ "LALT", WIN32_LINUX(VK_LMENU, SDL_SCANCODE_LALT) },
{ "LCTRL", WIN32_LINUX(VK_LCONTROL, SDL_SCANCODE_LCTRL) },
{ "LEFT", WIN32_LINUX(VK_LEFT, SDL_SCANCODE_LEFT) },
{ "LSHIFT", WIN32_LINUX(VK_LSHIFT, SDL_SCANCODE_LSHIFT) },
{ "M", WIN32_LINUX('M', SDL_SCANCODE_M) },
{ "MOUSE1", 0 },
{ "MOUSE2", 1 },
{ "MOUSE3", 2 },
{ "MOUSE4", 3 },
{ "MOUSE5", 4 },
{ "MULTIPLY", WIN32_LINUX(VK_MULTIPLY, SDL_SCANCODE_KP_MULTIPLY) },
{ "MWHEEL_DOWN", 0 },
{ "MWHEEL_UP", 0 },
{ "N", WIN32_LINUX('N', SDL_SCANCODE_N) },
{ "NONE", 0 },
{ "NUMPAD_0", WIN32_LINUX(VK_NUMPAD0, SDL_SCANCODE_KP_0) },
{ "NUMPAD_1", WIN32_LINUX(VK_NUMPAD1, SDL_SCANCODE_KP_1) },
{ "NUMPAD_2", WIN32_LINUX(VK_NUMPAD2, SDL_SCANCODE_KP_2) },
{ "NUMPAD_3", WIN32_LINUX(VK_NUMPAD3, SDL_SCANCODE_KP_3) },
{ "NUMPAD_4", WIN32_LINUX(VK_NUMPAD4, SDL_SCANCODE_KP_4) },
{ "NUMPAD_5", WIN32_LINUX(VK_NUMPAD5, SDL_SCANCODE_KP_5) },
{ "NUMPAD_6", WIN32_LINUX(VK_NUMPAD6, SDL_SCANCODE_KP_6) },
{ "NUMPAD_7", WIN32_LINUX(VK_NUMPAD7, SDL_SCANCODE_KP_7) },
{ "NUMPAD_8", WIN32_LINUX(VK_NUMPAD8, SDL_SCANCODE_KP_8) },
{ "NUMPAD_9", WIN32_LINUX(VK_NUMPAD9, SDL_SCANCODE_KP_9) },
{ "O", WIN32_LINUX('O', SDL_SCANCODE_O) },
{ "P", WIN32_LINUX('P', SDL_SCANCODE_P) },
{ "PAGE_DOWN", WIN32_LINUX(VK_NEXT, SDL_SCANCODE_PAGEDOWN) },
{ "PAGE_UP", WIN32_LINUX(VK_PRIOR, SDL_SCANCODE_PAGEUP) },
{ "Q", WIN32_LINUX('Q', SDL_SCANCODE_Q) },
{ "R", WIN32_LINUX('R', SDL_SCANCODE_R) },
{ "RALT", WIN32_LINUX(VK_RMENU, SDL_SCANCODE_RALT) },
{ "RCTRL", WIN32_LINUX(VK_RCONTROL, SDL_SCANCODE_RCTRL) },
{ "RIGHT", WIN32_LINUX(VK_RIGHT, SDL_SCANCODE_RIGHT) },
{ "RSHIFT", WIN32_LINUX(VK_RSHIFT, SDL_SCANCODE_RSHIFT) },
{ "S", WIN32_LINUX('S', SDL_SCANCODE_S) },
{ "SPACE", WIN32_LINUX(VK_SPACE, SDL_SCANCODE_SPACE) },
{ "SUBTRACT", WIN32_LINUX(VK_SUBTRACT, SDL_SCANCODE_KP_MINUS) },
{ "T", WIN32_LINUX('T', SDL_SCANCODE_T) },
{ "TAB", WIN32_LINUX(VK_TAB, SDL_SCANCODE_TAB) },
{ "U", WIN32_LINUX('U', SDL_SCANCODE_U) },
{ "UP", WIN32_LINUX(VK_UP, SDL_SCANCODE_UP) },
{ "V", WIN32_LINUX('V', SDL_SCANCODE_V) },
{ "W", WIN32_LINUX('W', SDL_SCANCODE_W) },
{ "X", WIN32_LINUX('X', SDL_SCANCODE_X) },
{ "Y", WIN32_LINUX('Y', SDL_SCANCODE_Y) },
{ "Z", WIN32_LINUX('Z', SDL_SCANCODE_X) },
{ "[", WIN32_LINUX(VK_OEM_4, SDL_SCANCODE_LEFTBRACKET) },
{ "\\", WIN32_LINUX(VK_OEM_5, SDL_SCANCODE_BACKSLASH) },
{ "]", WIN32_LINUX(VK_OEM_6, SDL_SCANCODE_RIGHTBRACKET) },
{ "`", WIN32_LINUX(VK_OEM_3, SDL_SCANCODE_GRAVE) }
});
As you can see i have included , And that's what i mostly read that you needed to do.
If anyone knows how to make std::to_array actually work, please reply.
Kind Regards.
std::to_array is available in C++20, not earlier versions.
Related
Finding text between two strings while containing a certain value [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question I've run into a problem when trying to find text between two strings while containing a certain value. I have a text string (see below): [ { "_attributes": { "id": "3190.7999" }, "jobs**": { "_attributes": { "count": "1" }, "CRJob": { "_attributes": { "id": "519" }, "jobID": "519", "toStatusNode": { "CRDataNode": { "_attributes": { "id": "4583" }, "dataNodeID": "4583" } } } } }, { "_attributes": { "id": "2966.7999" }, "**jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "2953.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "2952.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "2764.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "2629.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "2607.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "1096.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "1078.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "1034.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "960.7999" }, "jobs": { "_attributes": { "count": "1" }, "CRJob": { "_attributes": { "id": "238" }, "jobID": "238", "toStatusNode": { "CRDataNode": { "_attributes": { "id": "4585" }, "dataNodeID": "4585" } } } } }, { "_attributes": { "id": "844.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "638.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "633.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "601.7999" }, "jobs": { "_attributes": { "count": "0" } } } ] Target: I would like to return all text between “jobs” and “jobs” but only for the part where this text contains "4583". For the example above this would mean I would like to return: ": { "_attributes": { "count": "1" }, "CRJob": { "_attributes": { "id": "519" }, "jobID": "519", "toStatusNode": { "CRDataNode": { "_attributes": { "id": "4583" }, "dataNodeID": "4583" } } } } }, { "_attributes": { "id": "2966.7999" }, "jobs": { "_attributes": { "count": "0" } } }, { "_attributes": { "id": "2953.7999" }, " I’ve tried this: (?<=jobs).*(?=jobs) But this returns everything between the first and last “jobs”. I am unsure as to what I need to add to be able to only get the part that contains “4583”. How would I be able to do it?
Try this: (?<=jobs\")(?=.*4583.*).*?(?="jobs) Demo
icCube gauge with multiple band colors
I'm trying to make a gauge and want to have two band colors (wrong/red, good/green). I've an example of the amchart in their online Chart maker https://live.amcharts.com/new/edit/. But I'm not able to get this working in icCube. current we have icCube reporting version 7.0.0 (5549). This is my chart JSON: { "box": { "id": "wb695", "widgetAdapterId": "w28", "rectangle": { "left": 1510, "top": 340, "right": 1910, "bottom": 640 }, "zIndex": 901 }, "data": { "mode": "MDX", "schemaSettings": { "cubeName": null, "schemaName": null }, "options": { "WIZARD": { "measures": [], "rows": [], "rowsNonEmpty": false, "columns": [], "columnsNonEmpty": false, "filter": [] }, "MDX": { "statement": "with \n member [Measures].[Measure1] AS 0.9\n member [Measures].[Measure2] AS 0.1\nSELECT\n\n{[Measures].[Measure1], [Measures].[Measure2]} on 0\n\nFROM [cube]" }, "DATASOURCE": {} }, "ic3_name": "mdx Query-5", "ic3_uid": "m17" }, "data-render": { "chartType": { "label": "Gauge", "proto": { "chartPrototype": { "type": "gauge", "arrows": [ { "id": "GaugeArrow-1" } ], "axes": [ { "id": "GaugeAxis-1" } ] }, "graphPrototype": {}, "dataProviderType": 3 }, "id": "gauge-chart" }, "graphsConfiguration": [ { "graph": {} } ], "valueAxes": [], "trendLinesGuides": {}, "configuredQuadrants": {}, "advanced": { "titles": [], "faceAlpha": 0, "faceBorderAlpha": 0 }, "balloon": { "offsetX": 8 }, "chartOptions": { "axes": [ { "axisAlpha": 0.25, "bottomText": "SLA", "bottomTextColor": "#2A3F56", "tickAlpha": 0.25, "bandOutlineAlpha": 1, "bandAlpha": 1, "bandOutlineThickness": 95, "bandOutlineColor": "#0095BC", "id": 1 } ], "bands": [ { "alpha": 0.8, "color": "#B53728", "endValue": 0.6, "startValue": 0, "id": "GaugeBand-1" }, { "alpha": 0.6, "color": "#435035", "endValue": 1, "startValue": 0.6, "innerRadius": 0.69, "id": "GaugeBand-2" } ] }, "ic3Data": { "chartTypeConfig": { "pie-chart-donut": { "chartType": { "label": "Donut", "proto": { "chartPrototype": { "type": "donut", "pullOutRadius": 0, "startDuration": 0, "legend": { "enabled": false, "align": "center", "markerType": "circle" }, "innerRadius": "60%" }, "dataProviderType": 1 }, "id": "pie-chart-donut" }, "graphsConfiguration": [ {} ], "valueAxes": [], "trendLinesGuides": {}, "configuredQuadrants": {}, "advanced": { "titles": [] }, "balloon": { "offsetX": 8 }, "chartOptions": { "showZeroSlices": false, "labelsEnabled": false, "innerRadius": "60%", "startAngle": 270, "radius": "", "fontSize": 20, "color": "#0095BC", "outlineAlpha": 0.25, "tapToActivate": false } } } }, "axes": [ { "startValue": 0, "endValue": 1, "startAngle": -90, "endAngle": 90 } ], "valueFormatting": "" }, "navigation": { "menuVisibility": { "back": true, "axisXChange": "All", "axisYChange": "All", "filter": "All", "reset": true, "widget": true, "others": "All" }, "selectionMode": "disabled" }, "events": {}, "filtering": {}, "hooks": {} }
Sorry for the late answer, out of the box it's not possible but you can use hooks to change the javascript options sent to amcharts. JS / On Widget Options : function(context, options, $box) { const bands = [ { "color": "#00CC00", "endValue": 300000, "id": "GaugeBand-1", "startValue": 0 }, { "color": "#ffac29", "endValue": 600000, "id": "GaugeBand-2", "startValue": 300000 }, { "color": "#ea3838", "endValue": 900000, "id": "GaugeBand-3", "innerRadius": "95%", "startValue": 600000 } ]; options.axes[0]["bands"] = bands; return options; } This should work
loopback 3 string not matched with and condition
i am trying to filter with multiple value in loopback 3. 'AND condition' is not working. Numeric value filter working good but string value not matched. this is my condition is now : { "and": [{ "id": { "neq": "5d146f1f7a62651b8162fcf3" } }, { "gender": "male" }, { "age": { "between": [16, 60] } }, { "interestId": { "inq": ["5d11c0ce59e2b64e8dc12956", "5d11c0e259e2b64e8dc12958", "5d11c08659e2b64e8dc12953", "5d11c01759e2b64e8dc1294b", "5d11c03759e2b64e8dc1294d"] } }, { "location": { "near": { "lat": 26.8574194, "lng": 75.7977288 }, "maxDistance": 6, "unit": "kilometers" } }, { "maritalStatus": { "like": {} } }, { "college": { "like": {} } }, { "career": { "like": {} } }, { "currentJob": { "like": {} } }, { "height": { "between": [50, 89] } }, { "weight": { "between": [72, 192] } }, { "bodyBuild": "Slim" }] } String value is not push in array. if (interestId.highSchool && interestId.highSchool !="") { var highschool = new RegExp('.*' + interestId.highSchool + '.*', "i"); query.and.push({ highSchool: { like: highschool } }) } where is issue i don't understand. if i did't pass string value it's working fine.
Try following way:- if (interestId.highSchool && interestId.highSchool !="") { query.and.push({ highSchool: {regexp: new RegExp('.*' + interestId.highSchool + '.*', "i")} }) }
AWS API Gateway as proxy to dynamo DB HTTP Get mapping template
I have a API gateway which does a get to the tables stored in dynamo DB. The table stored looks like as JSON as show below { "photos": { "page": 1, "pages": "1234", "perpage": 100, "photo": [ { "farm": 1, "id": "12345678901", "isfamily": 0, "isfriend": 0, "ispublic": 1, "owner": "23456789#A12", "secret": "abc123d456", "server": "1234", "title": "Sample photo 1" }, { "farm": 2, "id": "23456789012", "isfamily": 0, "isfriend": 0, "ispublic": 1, "owner": "34567890#B23", "secret": "bcd234e567", "server": "2345", "title": "Sample photo 2" } ], "total": "123398" }, "srini": "srini" } With out integration response mapping template I get the table as shown below { "Count": 1, "Items": [ { "photos": { "M": { "photo": { "L": [ { "M": { "owner": { "S": "23456789#A12" }, "server": { "S": "1234" }, "ispublic": { "N": "1" }, "isfriend": { "N": "0" }, "farm": { "N": "1" }, "id": { "S": "12345678901" }, "secret": { "S": "abc123d456" }, "title": { "S": "Sample photo 1" }, "isfamily": { "N": "0" } } }, { "M": { "owner": { "S": "34567890#B23" }, "server": { "S": "2345" }, "ispublic": { "N": "1" }, "isfriend": { "N": "0" }, "farm": { "N": "2" }, "id": { "S": "23456789012" }, "secret": { "S": "bcd234e567" }, "title": { "S": "Sample photo 2" }, "isfamily": { "N": "0" } } } ] }, "perpage": { "N": "100" }, "total": { "S": "123398" }, "pages": { "S": "1234" }, "page": { "N": "1" } } }, "srini": { "S": "srini" } } ], "ScannedCount": 1 } I am trying to retrieve in the JSON format so that web client takes the table from Dynamo in JSON format .The mapping template I am trying to write is as follows #set($inputRoot = $input.path('$')) { #foreach($elem in $inputRoot.Items) { "srini": "$elem.srini.S", "pages": "$elem.photos.pages.S", #foreach($elemnext in $elem.photos.photo) { "id": "$elemnext.id.S" }#if($foreach.hasNext),#end #end }#if($foreach.hasNext),#end #end } I only can retrieve srini as show below Response Body { { "srini": "srini", "pages": "" } } All other data is not retreived ,What is the right way to write mapping template ,Can any one let me know please?
#set($inputRoot = $input.path('$')) { #foreach($elem in $inputRoot.Items) { "srini": "$elem.srini.S", "pages": "$elem.photos.M.pages.S", #foreach($elemnext in $elem.photos.M.photo.L) { "id": "$elemnext.M.id.S" } #if($foreach.hasNext),#end #end }#if($foreach.hasNext),#end #end }
c++ json-nlohmann accessing the list elements
I'm trying to use json-nlohmann library to read JSON files in C++ So far I got along with it preatty well, but now I'm trying to access elements of the list in given json. JSON: { "GameMap": "path_to_game_map", "Objects": [ { "object_1": { "Transform": { "Position": { "X": 1, "Y": 2 }, "Rotation": { "X": 3.5, "Y": 8.2 }, "Scale": { "X": 1, "Y":1 } }, "Components": [ { "0": { "data": { "some_data": "false" } } }, { "1": { "data": { "some_data": "false" } } }, { "2": { "data": { "some_data": "false" } } } ] } }, { "object_2": { "Transform": { "Position": { "X": 1, "Y": 2 }, "Rotation": { "X": 3.5, "Y": 8.2}, "Scale": { "X": 1, "Y":1 } }, "Components": [ { "0": { "data": { "some_data": "false" } } }, { "1": { "data": { "some_data": "false" } } }, { "2": { "data": { "some_data": "false" } } } ] } } ] } Where I'm trying to access each Component and read it's key value. I've got an object out for every Component. But I just cannot figure out how to read its key and value. Help! Please.
When you iterate a JSON object, say j, you can access the key and value like this: for (json::iterator it = j.begin(); it != j.end(); ++it) { std::cout << it.key() << " : " << it.value() << "\n"; } you can also now use for (auto& element : j.items()) and then element.key() and element.value() inside the loop.