Whole Tomato Software Forums
Whole Tomato Software Forums
Main Site | Profile | Register | Active Topics | Members | Search | FAQ
 All Forums
 Visual Assist
 Technical Support
 False dot converter for std::filesystem

You must be registered to post a reply.
Click here to register.

Screensize:
UserName:
Password:
Format: BoldItalicizeUnderlineStrikethrough Align leftCenterAlign right Insert horizontal ruleUpload and insert imageInsert hyperlinkInsert email addressInsert codeInsert quoted textInsert listInsert Emoji
   
Message:

Forum code is on.
Html is off.

 
Check to subscribe to this topic.
   

T O P I C    R E V I E W
tiancovici Posted - Aug 29 2020 : 05:38:04 AM

   if (fs::exists(root_path) && fs::is_directory(root_path))
   {
      for (auto const& dir_entry : fs::recursive_directory_iterator(root_path))
      {
         if(dir_entry->path().extension() == ".txt")
         cout << "Found cbt: {}" << dir_entry.path() << endl;
      }
   }


Visual Assist falsely determines to use -> instead of . operator for returned value of recursive_directory_iterator iterator

Visual Studio Info

Microsoft Visual Studio Professional 2019
Version 16.7.2
VisualStudio.16.Release/16.7.2+30413.136
Microsoft .NET Framework
Version 4.8.03752

Installed Version: Professional

Visual C++ 2019 00435-60000-00000-AA111
Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019 16.7.532.28833
ASP.NET and Web Tools 2019

Azure App Service Tools v3.0.0 16.7.532.28833
Azure App Service Tools v3.0.0

C# Tools 3.7.0-6.20412.3+d3c3a44a4e7ad31cc75c59be0d3df4a19ff33878
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension 1.0
IntelliCode Visual Studio Extension Detailed Info

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards

Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package

NuGet Package Manager 5.7.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

Test Adapter for Boost.Test 1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0
Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

Visual Assist 10.9.2382.0
For more information about Visual Assist, see the Whole Tomato Software website at http://www.WholeTomato.com. Copyright (c)1997-2020 Whole Tomato Software, LLC

Visual Basic Tools 3.7.0-6.20412.3+d3c3a44a4e7ad31cc75c59be0d3df4a19ff33878
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.10.0.0 for F# 4.7 16.7.0-beta.20361.3+3ef6f0b514198c0bfa6c2c09fefe41a740b024d5
Microsoft Visual F# Tools 10.10.0.0 for F# 4.7

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
4   L A T E S T    R E P L I E S    (Newest First)
feline Posted - Aug 31 2020 : 08:48:18 AM
The example missed a couple of points. First, the code only compiles in VS2019 if you go into the project settings and change the language to C++ 17, which is not the default setting. Secondly, you need to know that "fs" is defined as:

namespace fs = std::filesystem;

which I only figured out after working out why this didn't compile.

Having a working example, the dot is converted to -> when typed after the iterator "dir_entry". This is the default expected behaviour for a smart pointer iterator.

Taking a very simple example of a standard C++ library iterator, consider the code:

struct simpleData
{
	int m_nSize;
	int m_nCount;
};

void iterateAcrossSimpleListOfStruct()
{
	std::list<simpleData> listStruct;
	populateSimpleList(listStruct);
	int totalCount = 0;
	for (std::list<simpleData>::iterator it = listStruct.begin(); it != listStruct.end(); ++it)
	{
		// Test - typing dot after "it" is converted to "->" as expected for smart pointer
		it;
		totalCount += it->m_nCount;
	}
}

so why would you expect dot not to be converted to -> in your code?

If you place the caret into "dir_entry" and use Alt-Shift-G to use VA's Goto Related menu to view the members of the class recursive_directory_iterator, the class is a smart pointer. The default behaviour when using a smart pointer is to want the data inside the pointer, not the pointer members themselves, which is why dot is being converted to -> automatically.

Are you saying that recursive_directory_iterator is a special case smart pointer, and you would like VA to treat this class differently? If so this may well be possible.

The top of the page:

https://docs.microsoft.com/en-us/cpp/standard-library/recursive-directory-iterator-class?view=vs-2019

says:

Describes an input iterator that sequences through the filenames in a directory, possibly descending into subdirectories recursively. For an iterator X, the expression *X evaluates to an object of class directory_entry that wraps the filename and anything known about its status.

so the expectation seems to be that you will be using *dir_entry not dir_entry.
tiancovici Posted - Aug 30 2020 : 06:37:13 AM
Note while it fixes issue for std::filesystem's directory iterator it breaks for other frameworks (i.e. cxxopts from https://github.com/jarro2783/cxxopts)

i.e.

options.allow_unrecognised_options()
.add_options()
("d", "dir", cxxopts::value<string>()->default_value("."))


where cxxopts::value<string>() returns a shared pointer, but instead of "->", visual assist leaves it as a "."
tiancovici Posted - Aug 29 2020 : 10:08:32 AM
I don't understand why a simple use of standard c++ library isn't enough to reproduce it.

Both options were checked.
Un-checking Convert dot to -> if operator -> is overloaded
fixed the issue.
feline Posted - Aug 29 2020 : 09:13:45 AM
What do you have the two settings:

VA Options -> Editor -> Convert dot to -> in C/C++
Convert dot to -> if operator -> is overloaded

set to?

With a quick and simple test here I cannot reproduce the problem here, but it might be a difference in settings, or perhaps related to the surrounding code.

© 2023 Whole Tomato Software, LLC Go To Top Of Page
Snitz Forums 2000