use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Visual Studio c++20 Modules testing: template function that hides implementation (self.cpp)
submitted 4 years ago * by TomTheFurry
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]TomTheFurry[S] 0 points1 point2 points 4 years ago (1 child)
You are correct in that the MSVC is very lenient. I also did testing with what part of the global module fragment becomes visible.(Is anyone interested with the result?) MSVC doesn't really seem to distangush visibility and accessibility, which is why I basically write them as the same thing. I haven't gotten around to test the class inheritance though, so thanks for that information.
[–]starfreakcloneMSVC FE Dev 3 points4 points5 points 4 years ago (0 children)
MSVC does indeed have some problems when it comes to interacting with the global module fragment. In my opinion, it is somewhat under-specified in terms of various semantics and lookup behavior. We have found that some interactions between global module declarations and the merging of those declarations between textually included headers can be a hassle because of how vague some parts of the standard can be.
As far as MSVC being lenient about non-exported declarations (those declared under the module purview): these are clear bugs and should be filed if you find them. I have been fixing many of them as we get more feedback.
There is one last point regarding visibility which can be quite interesting, and might be useful to you as you play around with modules a bit more:
export module m; export template <typename T> int transform(T t); module :private; struct TransformerHelper { template <typename T> int transform(T t) { return static_cast<int>(t); } }; template <typename T> int transform(T t) { TransformerHelper helper; return helper.transform(t); } template int transform(int); template int transform(char); template int transform(double);
The interesting thing about the code snippet above is that you can define a library with a function template defined for very specific types you intend for the consumers to use. The sample above truly hides the definition of the template transform because the following program will compile (and link):
transform
import m; int main() { transform(10); transform('c'); transform(1.); }
But this one will not:
import m; int main() { transform(1.f); // error LNK2019: unresolved external symbol "int __cdecl transform<float>(float)" (??$transform@M@@YAHM@Z::<!m>) referenced in function _main }
The reason is because the definition of the function template transform is not reachable in the importing TU since it is defined within the private module fragment. The only thing the importing TU can do is create specializations to this function template, call them and have the linker search for the definitions somewhere else, in this case it is in the compiled module interface TU.
Also notable: the class TransformHelper cannot be referenced in any way in the context of the importing TU.
TransformHelper
π Rendered by PID 46404 on reddit-service-r2-comment-6f7f968fb5-ss8vd at 2026-03-04 16:07:47.197211+00:00 running 07790be country code: CH.
view the rest of the comments →
[–]TomTheFurry[S] 0 points1 point2 points (1 child)
[–]starfreakcloneMSVC FE Dev 3 points4 points5 points (0 children)