From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13214 invoked by alias); 14 Sep 2004 18:20:21 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 13190 invoked from network); 14 Sep 2004 18:20:17 -0000 Received: from unknown (HELO uvcms.net) (200.117.138.130) by sourceware.org with SMTP; 14 Sep 2004 18:20:17 -0000 Received: from [192.168.0.87] by uvcms.net (ArGoSoft Mail Server Pro for WinNT/2000/XP, Version 1.8 (1.8.5.9)); Tue, 14 Sep 2004 15:20:07 Message-ID: <41473666.3050308@uvcms.net> Date: Tue, 14 Sep 2004 18:20:00 -0000 From: Darko Miletic Organization: UVCMS User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) MIME-Version: 1.0 To: gcc help Subject: template issue Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-ArGoMail-Authenticated: darko X-SW-Source: 2004-09/txt/msg00132.txt.bz2 I have been playing with std::for_each and std::map and came with interresting issue: //main.cpp #include #include #include #include typedef std::map mapType; template inline void printMapValue(const M& value) { std::cout << value.first << " - " << value.second << "\n"; } template void print_map(const T& map_) { std::for_each( map_.begin(), map_.end(), printMapValue); // if typename is removed here GCC reports error??? std::cout << std::endl; } int main(int argc, char* argv[]) { mapType map_; map_[0] = "111"; map_[1] = "222"; map_[2] = "333"; print_map(map_); return 0; } If I remove keyword typename from print_map function GCC reports this: error: no matching function for call to `for_each( std::_Rb_tree_iterator, const std::pair&, const std::pair*>, std::_Rb_tree_iterator, const std::pair&, const std::pair*>, )' Why is typename needed here? Other compilers like BCB 5&6 and MSVC 7.1 compile this fine without typename keyword. Darko