Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8212463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:46:00+00:00 2026-06-07T10:46:00+00:00

I try to extend the boost::dynamic_bitset class with some functionality I need, such as

  • 0

I try to extend the boost::dynamic_bitset class with some functionality I need, such as counting bits after an AND operation, etc. Also I need access to the private members (m_num_bits, etc) because I want to be able to “override” the set() method to ensure the bitset’s capacity with the resize() fct, if the pos of the bit to set is greater then the current bitset capacity. If I use the native set() fct it throughs an assertion error in that case (because the set() method does not resize in such case)

I am not very experienced with templates, also I am just getting back into C++ since a few weeks, it’s a bit rusty, maybe somebody can help me out.

I started doing this:

template <typename Block, typename Allocator>
class ExtendedBitSet : public boost::dynamic_bitset<Block, Allocator> {
    typedef boost::dynamic_bitset<Block, Allocator> super;
public:
    void set(std::size_t pos) {
        if (pos > super::size())
            super::resize(pos);
        set(pos);
    }
    bool get(std::size_t pos) const {
        return super::test(pos);
    }
};

// ...

ExtendedBitSet<> * bs = new ExtendedBitSet<>(128);
bs->set(33);
// ...
std::wcout << "Bit 48 is " << ((bs->get(48) == true) ? "true" : "false") << std::endl;
// ...
delete bs;

Ofcourse this is not compiling, the error is:

dynamic_bitset.cpp: In function ‘int main(int, char**)’:
dynamic_bitset.cpp:50: error: wrong number of template arguments (0, should be 2)
dynamic_bitset.cpp:7: error: provided for ‘template<class T, class Allocator> class ExtendedBitSet’
dynamic_bitset.cpp:50: error: invalid type in declaration before ‘=’ token
dynamic_bitset.cpp:50: error: wrong number of template arguments (0, should be 2)
dynamic_bitset.cpp:7: error: provided for ‘template<class T, class Allocator> class ExtendedBitSet’
dynamic_bitset.cpp:51: error: request for member ‘set’ in ‘* bs’, which is of non-class type ‘int’
..
dynamic_bitset.cpp:57: error: request for member ‘get’ in ‘* bs’, which is of non-class type ‘int’

Can somebody give a hint how to get that running? Also is there maybe a better way than deriving from the dynamic_bitset class or is this OK to do?

Any help is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:46:02+00:00Added an answer on June 7, 2026 at 10:46 am

    Your ExtendedBitSet<> has no default parameters for the template type parameters and your code is trying to instantiate it without specifying them explicitly. Try using ExtendedBitSet<unsigned, std::allocator<unsigned> > bs instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to extend the CheckfrontAPI class with my new class. In my case
I am using Boost.Python to extend python program functionality. Python scripts do a lot
I try extend a class from networkx.DiGraph import networkx as nx class branch(nx.DiGraph): def
I try to extend the functionality of SimpleAudioEngine of cocos2d with the ability to
i try to extend Array object in javascript with some user friendly methods like
i realized that if you try to extend the SimpleAdapter class, you must make
As the title says, I try to extend the std::vector class in that way
Whenever I try to extend the Object prototype, I get an error: Error #1056:
I'm getting the following error when I try to extend SalatDAO or use grater[T].asObject(x):
i try to work with spinner on dialog public class data extends Dialog {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.