{"action":"created","issue":{"url":"https://api.github.com/repos/Keno/Cxx.jl/issues/246","repository_url":"https://api.github.com/repos/Keno/Cxx.jl","labels_url":"https://api.github.com/repos/Keno/Cxx.jl/issues/246/labels{/name}","comments_url":"https://api.github.com/repos/Keno/Cxx.jl/issues/246/comments","events_url":"https://api.github.com/repos/Keno/Cxx.jl/issues/246/events","html_url":"https://github.com/Keno/Cxx.jl/issues/246","id":148380244,"number":246,"title":"Interpolating literals into template class constructors","user":{"login":"KristofferC","id":1282691,"avatar_url":"https://avatars.githubusercontent.com/u/1282691?v=3","gravatar_id":"","url":"https://api.github.com/users/KristofferC","html_url":"https://github.com/KristofferC","followers_url":"https://api.github.com/users/KristofferC/followers","following_url":"https://api.github.com/users/KristofferC/following{/other_user}","gists_url":"https://api.github.com/users/KristofferC/gists{/gist_id}","starred_url":"https://api.github.com/users/KristofferC/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KristofferC/subscriptions","organizations_url":"https://api.github.com/users/KristofferC/orgs","repos_url":"https://api.github.com/users/KristofferC/repos","events_url":"https://api.github.com/users/KristofferC/events{/privacy}","received_events_url":"https://api.github.com/users/KristofferC/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-04-14T14:31:08Z","updated_at":"2016-04-15T03:47:33Z","closed_at":"2016-04-15T03:46:12Z","body":"Hi, I am playing around with calling the Eigen linalg library: http://eigen.tuxfamily.org/\r\n\r\nCreating a fixed size matrix templated on the element type and rows + columns using `icxx` work fine.\r\n```jl\r\njulia> using Cxx\r\n\r\njulia> cxx\"\"\"#include \"/home/kristoffer/Downloads/eigen-eigen-07105f7124f9/Eigen/Core\" \"\"\"\r\n\r\njulia> mat = icxx\"Eigen::Matrix<double, 4, 4>();\"\r\n(class Eigen::Matrix<double, 4, 4, 0, 4, 4>) {\r\n}\r\n```\r\n\r\nAlso, interpolating the element type into the `icxx` string works:\r\n```jl\r\njulia> T = Cfloat;\r\n\r\n# Interpolating the type into icxx string OK\r\njulia> mat = icxx\"Eigen::Matrix<$T, 4, 4>();\"\r\n(class Eigen::Matrix<float, 4, 4, 0, 4, 4>) {\r\n}\r\n```\r\n\r\nHowever, interpolating the rows or columns does not:\r\n\r\n```jl\r\njulia> rows = 4\r\n\r\njulia> mat = icxx\"Eigen::Matrix<$T, $rows, 4>();\"\r\nIn file included from :1:\r\n:2:29: error: non-type template argument is not a constant expression\r\nEigen::Matrix<__juliatype1, __juliavar2, 4>();\r\n                            ^~~~~~~~~~~\r\n:2:29: note: read of non-const variable '__juliavar2' is not allowed in a constant expression\r\n:1:1: note: declared here\r\n```\r\n\r\nI realize that this is because only types are swapped out to be `__juliatype` in the `icxx` macro and the rest gets passed as non constant `__juliavar`s. Is there any way to wrap the literal or something to make interpolating the rows and columns work?\r\n\r\nThanks!\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Keno/Cxx.jl/issues/comments/210272096","html_url":"https://github.com/Keno/Cxx.jl/issues/246#issuecomment-210272096","issue_url":"https://api.github.com/repos/Keno/Cxx.jl/issues/246","id":210272096,"user":{"login":"Keno","id":1291671,"avatar_url":"https://avatars.githubusercontent.com/u/1291671?v=3","gravatar_id":"","url":"https://api.github.com/users/Keno","html_url":"https://github.com/Keno","followers_url":"https://api.github.com/users/Keno/followers","following_url":"https://api.github.com/users/Keno/following{/other_user}","gists_url":"https://api.github.com/users/Keno/gists{/gist_id}","starred_url":"https://api.github.com/users/Keno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Keno/subscriptions","organizations_url":"https://api.github.com/users/Keno/orgs","repos_url":"https://api.github.com/users/Keno/repos","events_url":"https://api.github.com/users/Keno/events{/privacy}","received_events_url":"https://api.github.com/users/Keno/received_events","type":"User","site_admin":false},"created_at":"2016-04-15T03:47:33Z","updated_at":"2016-04-15T03:47:33Z","body":"Making this work as is would significantly pessimize all other code. However, I've implemented something that should work just fine. Regular warnings regarding overspecialization apply:\r\n```\r\njulia> rows = Val{4}\r\n\r\njulia> mat = icxx\"Eigen::Matrix<$T, $rows, 4>();\"\r\n```"}}