Click here to Skip to main content
15,880,972 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings Kind Regards
The routines below do not compile w/ error messages shown. I am mostly interested in the first routine assert_Search_results The error refers to a template parameter being shadowed. I do not know what that means. I seek your kind assistance. Thank You Kindly

Solution found. See below.

C++
import std.core;
using namespace std;

#define LINE_FUNCSIG cout << __LINE__ << ' ' << __FUNCSIG__ << endl;

namespace TREE
{
	template<typename treeType, template<typename> typename keyReferenceWrapper, template<typename> typename valueReferenceWrapper>
	struct key_x_value {};
}

template<typename T>
struct non_reference_wrapper {};

struct cContiguousIntervalTree
{
	using this_tree_type = cContiguousIntervalTree;

	template<typename T>
	using key_reference_wrapper = non_reference_wrapper<T>;

	template<template<typename> typename valueReferenceWrapper>
	using key_x_value_template = TREE::key_x_value<this_tree_type, key_reference_wrapper, valueReferenceWrapper>;

	template<template<typename> typename referenceWrapper>
	using intersecting_x_datum_template = key_x_value_template<referenceWrapper>;
};

// does not compile
// error C2947 : expecting '>' to terminate template - argument - list, found '<'
// error C7576 : declaration of 'referenceWrapper' shadows a template parameter
// error C2988 : unrecognizable template declaration / definition
// error C2143 : syntax error : missing ')' before '>'
// error C2059 : syntax error : '>'
// error C2059 : syntax error : ')'
// Done building project "hello_world.vcxproj" --FAILED.
template<typename treeType, template<typename> class referenceWrapper>
void assert_Search_result(const vector<typename treeType::intersecting_x_datum_template<referenceWrapper>>);

// does not compile
// error C2988 : unrecognizable template declaration / definition
// error C2143 : syntax error : missing ')' before '<'
// error C2143 : syntax error : missing ';' before '<'
// error C2059 : syntax error : '<'
// error C2059 : syntax error : ')'
// Done building project "hello_world.vcxproj" --FAILED.
template<typename T, typename U>
void foo(typename T::key_reference_wrapper);

// much to my amazement compiles
template<typename T, typename U>
void goo(typename T::U); 

Solution:
C++
template<typename treeType, template<typename> typename referenceWrapper, typename U>
void assert_Search_result(typename treeType:: template intersecting_x_datum_template<referenceWrapper<U>>);

Invoked as:
C++
assert_Search_result<defined_tree_type_here, defined_reference_wrapper_type_here>(argument_here);


What I have tried:

Examined cppreference page link below re / dependent type. Was not helpful. Examined Microsoft page link below re / error C7576. Was not helpful. Searched web for "template shadow". Found nothing. Examined code above to determine why all these underlines. Was not helpful. Finally learned < and > need to be converted to &lt and &gt
Dependent names - cppreference.com< / a>[ ^ ]
Compiler errors C7500 through C7999 | Microsoft Learn[ ^ ]
Posted
Updated 5-Nov-22 1:04am
v3
Comments
BernardIE5317 5-Nov-22 6:47am    
I re-posted because I concluded the original post was somehow lost as I did not see it on the list of New C++ questions. I do not see this question on the list either so I do not know how you found it. If I can not find it how can anyone else.
Richard MacCutchan 5-Nov-22 7:25am    
Click on your name to go to your home page, and there are links to all your messages, questions, comments etc.
BernardIE5317 5-Nov-22 7:29am    
Thank You for your interest. However it does not help me if I can find my questions via my home page. It only helps me if others can find it via the New Questions list which does not display this question.
Richard MacCutchan 5-Nov-22 7:38am    
Well that is the way the site works, and for the majority here it is perfectly acceptable. If you think your question is not getting any attention then you can always edit it via the Improve question link, and add more information. That will bring it back to the front of the queue. But please do not use that unless you are actually adding more useful information. Just editing it to get to the front of the queue is more likely to get it deleted. And finally, just because you post a question here does not guarantee an answer. If you don't get any useful feedback it could just mean that no one here knows the answer.
BernardIE5317 5-Nov-22 8:04am    
Thank You for your continued interest. May I please inquire as the "New" C++ Questions seem to be in chronological order what should I conclude if my question does not appear going back a month. May I also please inquire how you found this question as I still can not.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900